A database backup is the procedure of storing CUBRID database volumes, control files and log files, and it is executed by using the cubrid backupdb utility or the CUBRID Manager. DBA must regularly back up the database so that the database can be properly restored in the case of storage media or file errors. The restore environment must have the same operating system and the same version of CUBRID as the backup environment. For such a reason, you must perform a backup in a new environment immediately after migrating a database to a new version.
To recover all database pages, control files and the database to the state at the time of backup, the cubrid backupdb utility copies all necessary log records.
cubrid backupdb [ options ] database_name
[ options ]
-D | -r | -l | -o | -S | -C | -t | -z | -e |
--destination-path | --remove-archive | --level | --output-file | --SA-mode | --CS-mode | --thread-count | --compress | --except-active-log | --no-check
The following table shows options available with the cubrid backupdb utility (options are case sensitive).
Option |
Description |
---|---|
-D |
Specifies the directory path name or device name where backup volumes are to be created. |
-r |
Removes unnecessary archive logs after the backup is complete. |
-l |
Specifies the backup level to 0, 1 or 2. |
-o |
Specifies the name of the file where progress information is to be displayed. |
-S |
Performs a backup in standalone mode. |
-C |
Performs a backup in client/server mode. |
-t |
Specifies the maximum number of threads allowed for a parallel backup. |
-z |
Performs a compressed backup. |
-e |
Specifies that active log volumes are not included in the backup. |
--no-check |
Does not perform a consistency check on a database before making a backup. |
Performing backup by specifying the directory in which backup files are to be stored (-D or --destination-path)
The following example shows how to use the -D option to store backup files in the specified directory. The backup file directory must be specified before performing this job. If the -D option is not specified, backup files are stored in the directory specified in the databases.txt file which stores database location information.
cubrid backupdb -D /home/cubrid/backup demodb
The following example shows how to store backup files in the current directory by using the -D option. If you enter a period (.) following the -D option as an argument, the current directory is specified.
cubrid backupdb -D . demodb
Removing archive logs after backup (-r or --remove-archive)
If the system parameter media_failure_support is configured to 1, when the active logs are full, they are written to a new archive log file. If a backup is performed in such a situation and backup volumes are created, backup logs created before the backup will not be used in subsequent backups. The -r option is used to remove archive log files that will not be used any more in subsequent backups after the current one is complete.
cubrid backupdb -r demodb
The -r option does not affect the restore because it removes only unnecessary archive logs before the backup, but full restore may not be possible if the administrator removes archive logs created after the backup as well; when you remove archive logs, you must check if those logs would be required in any subsequent restore.
If you perform an incremental backup (backup level 1 or 2) with the -r option, there is the risk that normal recovery of the database will be impossible later on. Therefore, it is recommended that the -r option only be used when a full backup is performed.
Performing a backup with the backup level specified (-l or --level)
The following example shows how to execute an incremental backup of the level specified by using the -l option. If the -l option is not specified, a full backup is performed. For details on backup levels, see Incremental Backup.
cubrid backupdb -l 1 demodb
Storing backup progress information in the specified file (-o or --output-file)
The following example shows how to write the progress of the database backup to the info_backup file by using the -o option.
cubrid backupdb -o info_backup demodb
The following example shows the contents of the info_backup file. You can check the information on the number of threads, compression method, backup start time, the number of permanent volumes, backup progress and backup end time.
[ Database(demodb) Full Backup start ]
- num-threads: 1
- compression method: NONE
- backup start time: Mon Jul 21 16:51:51 2008
- number of permanent volumes: 1
- backup progress status
-----------------------------------------------------------------------------
volume name | # of pages | backup progress status | done
-----------------------------------------------------------------------------
demodb_vinf | 1 | ######################### | done
demodb | 25000 | ######################### | done
demodb_lginf | 1 | ######################### | done
demodb_lgat | 25000 | ######################### | done
-----------------------------------------------------------------------------
# backup end time: Mon Jul 21 16:51:53 2008
[Database(demodb) Full Backup end]
Performing backup in standalone mode (-S or --SA-mode)
The following example shows how to execute backup in standalone by using the -S option. The demodb database is backed up offline. If the -S option is not specified, the backup is performed in the client/server mode.
cubrid backupdb -S demodb
Performing backup in client/server mode (-C or --CS-mode)
The following example shows how to execute backup in client/server mode by using the -C option. The demodb database is backed up online. If the -C option is not specified, a backup is performed in the client/server mode.
cubrid backupdb -C demodb
Parallel backup (-t or --thread-count)
The following example shows how to execute parallel backup with the number of threads specified by the administrator by using the -t option. Even when the argument of the -t option is not specified, a parallel backup is performed by automatically assigning as many threads as CPUs in the system.
cubrid backupdb -t 4 demodb
Compressed backup (-z or --compress)
The following example shows how to compress the database and stores it in the backup file by using the -z option. The size of the backup file and the time required for backup can be reduced by using the -z option.
cubrid backupdb -z demodb
Enabling to exclude active log volumes (-e or --except-active-log)
The following example shows how to execute backup excluding active logs of the database by using the -e option. You can reduce the time required for backup by using the -e option. However, extra caution is required because active logs needed for completing a restore to the state of a certain point from the backup point are not included in the backup file, which may lead to an unsuccessful restore.
cubrid backupdb -e demodb
Disabling database consistency check (--no-check)
The following example shows how to execute backup without checking the consistency of the database by using the --no-check option.
cubrid backupdb --no-check demodb