A database restore is the procedure of restoring the database to its state at a certain point in time by using the backup files, active logs and archive logs which have been created in an environment of the same CUBRID version. To perform a database restore, use the cubrid restoredb utility or the CUBRID Manager.
The cubrid restoredb utility (restordb.exe on Windows) restores the database from the database backup by using the information written to all the active and archive logs since the execution of the last backup.
cubrid restoredb [ options ] database_name
[ options ]
-d | -B | -l | -p | -o | -u |
--up-to-date | --backup-file-path | --level | --partial-recovery | --output-file | --use-database-location-path | --list
The following table shows options available with the cubrid restoredb utility (options are case sensitive).
Directly sets the time to backup the database or specifies the backuptime keyword.
Specifies the directory pathname or device name where backup files are to be located.
Sets the restoration level to 0, 1 or 2.
Performs a partial restoration.
Specifies the name of the file where restoration information is to be displayed.
Restores the database to the path specified in the database location file (databases.txt).
Displays information on backup volumes of the database on the screen.
Performing restoration by specifying a specific point (-d or --up-to-date)
The following syntax shows how to restore a database. If no option is specified, a database is restored to the point of the last commit by default. If no active/archive log files are required to restore to the point of the last commit, the database is restored only to the point of the last backup.
cubrid restoredb demodb
A database can be restored to the given point by using the -d option and the command which specifies the date and time of the restoration. The user can specify the restoration point manually in the dd-mm-yyyy:hh:mm:ss (e.g. 14-10-2008:14:10:00) format. If no active log/archive log files are required to restore to the point specified, the database is restored only to the point of the last backup.
cubrid restoredb -d 14-10-2008:14:10:00 demodb
The following command specifies the restoration point by using the -d option and the backuptime keyword and restores a database to the point of the last backup.
cubrid restoredb -d backuptime demodb
Performing restoration by specifying the directory path to a backup file (-B or --backup-file-path)
You can specify the directory where backup files are to be located by using the -B option. If this option is not specified, the system retrieves the backup information file (dbname_bkvinf) generated upon a database backup; the backup information file in located in the log-path directory specified in the database location information file (databases.txt). And then it searches the backup files in the directory path specified in the backup information file. However, if the backup information file has been damaged or the location information of the backup files has been deleted, the system will not be able to find the backup files. Therefore, the administrator must manually specify the directory where the backup files are located by using the -B option.
cubrid restoredb -B /home/cubrid/backup demodb
If the backup files of a database is in the current directory, the administrator can specify the directory where the backup files are located by using the -B option.
cubrid restoredb -B . demodb
Performing restoration by specifying backup level (-l or --level)
You can perform restoration by specifying the backup level of the database to 0, 1, or 2. For details on backup levels, see Increment Backup.
cubrid restoredb -l 1 demodb
Performing partial restoration (-p or --partial-recovery)
The following syntax shows how to perform partial restoration without requesting for the user's response by using the -p option. If active or archive logs written after the backup point are not complete, by default the system displays a request message informing that log files are needed and prompting the user to enter an execution option. The partial restoration can be performed directly without such a request message by using the -p option. Therefore, if the -p option is used when performing restoration, data is always restored to the point of the last backup.
cubrid restoredb -p demodb
When the -p option is not specified, the message requesting the user to select the execution option is as follows:
Log Archive /home/cubrid/test/log/demodb_lgar002
is needed to continue normal execution.
- 0 to quit.
- 1 to continue without present archive. (Partial recovery)
- 2 to continue after the archive is mounted/loaded.
- 3 to continue after changing location/name of archive.
Storing restore progress information in the specified file (-o or --output-file)
The following syntax shows how to write the restoration progress of a database to the info_restore file by using the -o option.
cubrid restoredb -o info_restore demodb
Restoring data to the directory specified in the database location file (-u or --use-database-location-path)
The following syntax shows how to restore a database to the path specified in the database location file (databases.txt) by using the -u option. The -u option is useful when you perform a backup on server A and store the backup file on server B.
cubrid restoredb -u demodb
Checking the backup information of a database (--list)
The following syntax shows how to display information on backup files of a database by using the --list option; restoration procedure is not performed with this command.
cubrid restoredb --list demodb
The following example shows how to display backup information by using the --list option. You can specify the path to which backup files of the database are originally stored as well as backup levels.
*** BACKUP HEADER INFORMATION ***
Database Name: /local1/testing/demodb
DB Creation Time: Mon Oct 1 17:27:40 2008
Backup Level: 1 (INCREMENTAL LEVEL 1)
Backup Time: Mon Oct 1 17:32:50 2008
Backup Unit Num: 0
Disk Version: 8
Backup Pagesize: 4096
Zip Method: 0 (NONE)
Zip Level: 0 (NONE)
Previous Backup level: 0 Time: Mon Oct 1 17:31:40 2008
(start_lsa was -1|-1)
Database Volume name: /local1/testing/demodb_vinf
Volume Identifier: -5, Size: 308 bytes (1 pages)
Database Volume name: /local1/testing/demodb
Volume Identifier: 0, Size: 2048000 bytes (500 pages)
Database Volume name: /local1/testing/demodb_lginf
Volume Identifier: -4, Size: 165 bytes (1 pages)
Database Volume name: /local1/testing/demodb_bkvinf
Volume Identifier: -3, Size: 132 bytes (1 pages)
With the backup information displayed by using the --list option, you can check that backup files have been created at the backup level 1 as well as the point where the full backup of backup level 0 has been performed. Therefore, to restore the database in the example, you must prepare backup files for backup levels 0 and 1.