Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Versions available for this page: CUBRID 8.4.1 |  CUBRID 8.4.3 |  CUBRID 9.0.0 | 

Restoring Database

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.

Syntax

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

  • cubrid: An integrated utility for the CUBRID service and database management.
  • restoredb: A command for restoration of the specified database. For a successful restoration, you must prepare backup files, active log files and archive log files. This command can be performed only in standalone mode.
  • options: A short name option starts with a single dash (-) while a full name option starts with a double dash (--). This option is case sensitive.
  • database_name: Specifies the name of the database to be restored.
Return Value
  • 0: Success
  • Non-zero: Failure
Options

The following table shows options available with the cubrid restoredb utility (options are case sensitive).

Option

Description

-d
--up-to-date

Directly sets the time to backup the database or specifies the backuptime keyword.

-B
--backup-file-path

Specifies the directory pathname or device name where backup files are to be located.

-l
--level

Sets the restoration level to 0, 1 or 2.
The default value is full restoration (0).

-p
--partial-recovery

Performs a partial restoration.

-o
--output-file

Specifies the name of the file where restoration information is to be displayed.

-u
--use-database-location-path

Restores the database to the path specified in the database location file (databases.txt).

--list

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.

   Type

   -  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.

***********************************************************

  • Option 0: Stops restoring
  • Option 1: Performing partial restoration without log files.
  • Option 2: Performing restoration after locating a log to the current device.
  • Option 3: Resuming restoration after changing the location of a log

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

         Pagesize: 4096

Backup Level: 1 (INCREMENTAL LEVEL 1)

        Start_lsa: 513|3688

         Last_lsa: 513|3688

Backup Time: Mon Oct 1 17:32:50 2008

 Backup Unit Num: 0

Release: 8.1.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.