Difference between revisions of "Backup and Restore Databases"

From Recital Documentation Wiki
Jump to: navigation, search
 
Line 86: Line 86:
  
 
===Using the Recital Rollback Timeline Command to Rollback to a Timeline===
 
===Using the Recital Rollback Timeline Command to Rollback to a Timeline===
==Database Timelines==
+
Database timelines provide row versioning for Recital database applications. Whenever a change is made to a table that is timeline enabled, delta changes are automatically recorded for each transaction. Changes made to any tables that are timeline enabled can be ''undone'' using the [[ROLLBACK TIMELINE|rollback timeline]] command.
===What are Database Timelines?===
+
Database timelines provide row versioning for Recital database applications. Whenever a change is made to a table that is timeline enabled then delta changes are automatically recorded for each transaction. Changes made to any tables that are timeline enabled can be '''undone''' much like you would undo changes to program code that you edit in a text editor.
+
  
===Using Database Timelines===
+
For full details on database timelines, please see the [[Database Timelines]] section.
To enable database timelines all you need to do is issue the [[SET TIMELINE|set timeline on]] command in your Recital configuration file.
+
 
+
<pre>
+
set timeline on
+
</pre>
+
 
+
====Viewing a timeline====
+
There are 2 ways to view a timeline.
+
 
+
* The [[LIST TIMELINE|list timeline]] command
+
* The [[SYSTIMELINE|select * from systimeline]] SQL command
+
 
+
<pre>
+
list timeline [range <begin as string-date> [, <end as string-date>]] [for <condition as logical>] [to file <filename as character>]
+
</pre>
+
 
+
To view a timeline for a particular table e.g.
+
 
+
<pre>
+
list timeline for table = "customers"
+
</pre>
+
 
+
To view a timeline since a certain date use the '''range''' keyword. Notice that the date range is encoded as a string in the format "YYYYMMDDHH:MM:SS:". This can be abbreviated  e.g.
+
 
+
<pre>
+
// list the timeline since 1st October 2009
+
list timeline range "20091001"
+
 
+
// list the timeline between the 1st and 7th of October 2009
+
list timeline range "20091001","20091007"
+
</pre>
+
 
+
[[SQL SELECT]] can be used with the Recital Data Object functions (rdo_xxx() functions) to traverse the timeline and generate html if required e.g.
+
 
+
<code lang="recital">
+
echo "Timeline report<br>"
+
results = rdo_query("SELECT * FROM systimeline WHERE between(timestamp, '20091001', '20091007')")
+
foreach results as row
+
    echo "Table " + row["TABLE"] + " changed by " + row["USER"] + " on " + row["TIMESTAMP"]
+
    echo ", command was " + row["COMMAND"] + "<br>"
+
endfor
+
results = null
+
</code>
+
 
+
====Undoing database changes====
+
You can undo database changes with the [[ROLLBACK TIMELINE|rollback timeline]] command. The '''range''' and '''for''' clauses can also be specified in the same way as the [[LIST TIMELINE|list timeline]] command e.g.
+
 
+
<pre>
+
rollback timeline [range <begin as string-date> [, <end as string-date>]] [for <condition as logical>]
+
</pre>
+
 
+
====Clearing a  timeline====
+
The [[CLEAR TIMELINE|clear timeline]] command will reset a timeline.
+
 
+
<pre>
+
clear timeline
+
</pre>
+
 
+
===Summary===
+

Latest revision as of 10:19, 16 March 2010

Backup and Restore Databases

Using the recitaldump Command to Backup Your Data

The recitaldump command is used to perform backups of either a database or a directory tree. The format of the backup file is machine independent and can be restored onto another machine with a different architecture e.g. backup on aix and restore on linux. You use the recitalrestore command to restore the backup onto another machine.

Note: recitaldump and recitalrestore must be run as root. For systems with a hidden root account, please precede the commands with sudo.

The recitaldump command takes the following arguments.

--help

Using the --help or -h argument will display a list of arguments for all the services.

 recitaldump --help

-D database

This argument is used to specify the name of a database to backup. If no -o output file is specified, the backup file will be given the same basename as the database, with a .tar.gz extension.

 recitaldump -D southwind 

-d directory

This argument is used to specify the name of a directory to backup. If no -o output file is specified, the backup file will be given the same basename as the directory, with a .tar.gz extension. If there is a file called _reindex.prg located in the directory this file will be executed to recreate single index files when the backup is restored on a target system. You should add the Recital script commands used to rebuild the index files (.ndx) into this file. Multiple tag index files (.dbx) are handled automatically.

 recitaldump -d /data/application 

-r

This argument is used in conjunction with the -d option to recursively process subdirectories.

recitaldump -d /data/application -r 

-o outfile

Specify the output backup file name. When you need to restore this file use the recitalrestore command. For example to create a backup file of the southwind database called accountants.tar.gz;

 recitaldump -D southwind -o accountants

-t

This argument is used to add a time stamp to the output file name. For example if today was the 2nd of November 2009 at 03:27pm the following command would create a file called southwind-20091102-1527.tar.gz from backing up the southwind database.

 recitaldump -D southwind -t

Using the recitalrestore Command to Restore Your Data

The recitalrestore utility is is used to restore a backup archive created using the recitaldump command. The recitaldump command can be used to create a machine independent backup of a database or directory which is restored onto a target system using recitalrestore.

Note: recitalrestore must be run as root. For systems with a hidden root account, please precede commands with sudo.

The recitalrestore command takes the following arguments.

--help

Using the --help or -h argument will display a list of arguments for all the services.

 recitalrestore --help

-i infile

Specify the input backup file that was created from recitaldump to restore from. If the backup is of a directory, the full path name of the backup file must be specified.

 recitalrestore -i /tmp/application.tar.gz

For a database, only the file name need be given.

 recitalrestore -i southwind.tar.gz

[ -q ]

Run in quiet mode.

 recitalrestore -i southwind.tar.gz -q

[ -v ]

Run in verbose mode.

 recitalrestore -i southwind.tar.gz -v

Using the Recital Rollback Timeline Command to Rollback to a Timeline

Database timelines provide row versioning for Recital database applications. Whenever a change is made to a table that is timeline enabled, delta changes are automatically recorded for each transaction. Changes made to any tables that are timeline enabled can be undone using the rollback timeline command.

For full details on database timelines, please see the Database Timelines section.