Restoring Database to Different Server
The following shows how to back up demodb on server A and restore it on server B with the backed up files.
Backup and Restore Environments
Suppose that demodb is backed up in the /home/cubrid/db/demodb directory on server A and restored into /home/cubrid/data/demodb on server B.
- Backing up on server A
- Back up demodb on server A. If a backup has been performed earlier, you can perform an incremental backup for data only that have changed since the last backup. The directory where the backup files are created, if not specified in the -D option, is created by default in the location where the log volume is stored. The following is a backup command with recommended options. For details on the options, see Database Backup.
- cubrid backupdb -z -t demodb
- Editing the database location file on Server B
- Unlike a general scenario where a backup and restore are performed on the same server, in a scenario where backup files are restored using a different server, you need to add the location information on database restore in the database location file (databases.txt) on server B. In the diagram above, it is supposed that demodb is restored in the /home/cubrid/data/demodb directory on server B (hostname: pmlinux); edit the location information file accordingly and create the directory on server B.
- Put the database location information in one single line. Separate each item with a space. The line should be written in [database name]. [data volume path] [host name] [log volume path] format; that is, write the location information of demodb as follows:
- demodb /home/cubrid/data/demodb pmlinux /home/cubrid/data/demodb
- Transferring backup/log files to server B
- For a restore, you must prepare a backup file (e.g. demodb_bk0v000) and a backup information file (e.g. demodb_bkvinf) of the database to be backed up. To restore the entire data up to the point of the last commit, you must prepare an active log (e.g. demodb_lgat) and an archive log (e.g. demodb_lgar000). Then, transfer the backup information, active log, and archive log files created on server A to server B. That is, the backup information, active log and archive log files must be located in a directory (e.g. /home/cubrid/temp) on server B.
- Restoring the database on server B
- Perform database restore by calling the cubrid restoredb utility from the directory into which the backup, backup information, active log and archive log files which were transferred to server B had been stored. With the -u option, demodb is restored in the directory path from the databases.txt file.
- cubrid restoredb -u demodb
- To call the cubrid restoredb utility from a different path, specify the directory path to the backup file by using the -B option as follows:
- cubrid restoredb -u -B /home/cubrid/temp demodb
- Backing up the restored database on server B
- Once the restore of the target database is complete, run the database to check if it has been properly restored. For stable management of the restored database, it is recommended to restore the database again on the server B environment.