BACKUP v2.6
Use the BACKUP
subcommand to create a full or incremental backup.
Syntax for a Full Backup:
bart BACKUP –s { <server_name> | all } [ -F { p | t } ] [ -z ] [ –c <compression_level> ] [ --backup-name <backup_name> ] [ --thread-count <number_of_threads> ] [ { --with-pg_basebackup | --no-pg_basebackup } ]
Syntax for an Incremental Backup:
bart BACKUP –s <server_name> [-Fp] [ --parent { <backup_id> | <backup_name> } ] [ --backup-name <backup_name> ] [ --thread-count <number_of_threads> ] [ { --checksum-algorithm } ]
Before performing an incremental backup, you must take a full backup. For more details about incremental backup, refer to Block-Level Incremental Backup in the EDB Backup and Recovery User Guide available at the EDB website.
The following table describes the BACKUP
options:
Options | Description |
---|---|
-s { <server_name> | all } --server { <server_name> | all } | Use this option to specify the database server to be backed up. Specify <server_name> to take a backup of the database server (as specified in the BART configuration file).Specify all to take a backup of all servers. |
-F { p | t } --format { p | t } | Use this option to specify the backup file format. Specify p option to take backup in plain text format and specify t option to take backup in tar format. If the p or t option is omitted, the default is tar format.Use p option with the BACKUP subcommand when streaming is used as a backup method.An incremental backup can only be taken in plain text format ( p ). |
-z (--gzip) | This option is applicable only for full backup and tar format. Use this option to enable gzip compression of tar files using the default compression level (typically 6). |
-c <compression_level> --compress-level <compression_level> | This is applicable only for full backup and tar format. Use this option to specify the gzip compression level on the tar file output. <compression_level> is a digit from 1 through 9, with 9 being the best compression. |
--backup-name <backup_name> | Use this option to assign a user-defined, alphanumeric friendly name to the backup. The maximum permitted length of backup name is 49 characters. For detailed information about this parameter, see the EDB Backup and Recovery User Guide available at the EDB website. If the option --backup-name is not specified and the backup_name parameter is not set for this database server in the BART configuration file, then the backup can only be referenced in other BART subcommands by the BART assigned backup identifier. |
--thread-count <number_of_threads> | Use this option to specify the number of worker threads to run in parallel to copy blocks for a backup. For detailed information about the --thread-count parameter, see the EDB Backup and Recovery Installation and Upgrade Guide available at the EDB website. |
--with-pg_basebackup | This is applicable only for full backup. Use this option to specify the use of pg_basebackup to take a full backup. The number of thread counts in effect is ignored as given by the thread_count parameter in the BART configuration file.When taking a full backup, if the thread count in effect is greater than 1 , then the pg_basebackup utility is not used to take the full backup (parallel worker threads are used) unless the --with-pg_basebackup option is specified with the BACKUP subcommand. |
--no-pg_basebackup | This is applicable only for full backup. Use this option to specify that pg_basebackup is not to be used to take a full backup.When taking a full backup, if the thread count in effect is only 1 , then the pg_basebackup utility is used to take the full backup unless the --no-pg_basebackup option is specified with the BACKUP subcommand. |
--parent { <backup_id> | <backup_name> } | Use this option to take an incremental backup. The parent backup is a backup taken prior to the incremental backup; it can be either a full backup or an incremental backup. <backup_id> is the backup identifier of a parent backup and <backup_name> is the user-defined alphanumeric name of a parent backup. |
--check | This is applicable only for incremental backup. Use this option to verify if the required MBM files are present in the BART backup catalog before taking an incremental backup. However, an actual incremental backup is not taken when the --check option is specified.The --parent option must be used along with the --check option. |
--checksum-algorithm | While taking a backup, you can specify one of the following values with the --checksum-algorithm option:--checksum-algorithm=MD5 (default) to generate MD5 checksum files.--checksum-algorithm=SHA256 to generate SHA256 checksum files.--checksum-algorithm=NONE to skip generating checksum files. |
Examples
The following code sample demonstrates using variables with the BACKUP
subcommand:
./bart backup -s ppas12 -Ft --backup-name "YEAR = %year MONTH = %month DAY = %day"
./bart backup -s ppas12 -Ft --backup-name "YEAR = %year MONTH = %month DAY = %day %%"
./bart show-backups -s ppas12 -i "test backup"
The following code sample displays the result of creating a full backup in the default tar format with gzip compression when the BACKUP
subcommand was invoked. Note that checksums are generated for the full backup and user-defined tablespaces for the tar format backup:
[edb@localhost bin]$ ./bart BACKUP -s hr -z INFO: DebugTarget - getVar(checkDiskSpace.bytesAvailable) INFO: new backup identifier generated 1567591909098 INFO: creating 5 harvester threads NOTICE: all required WAL segments have been archived INFO: backup completed successfully INFO: BART VERSION: 2.5 BACKUP DETAILS: BACKUP STATUS: active BACKUP IDENTIFIER: 1567591909098 BACKUP NAME: none BACKUP PARENT: none BACKUP LOCATION: /home/edb/bkup_new/hr/1567591909098 BACKUP SIZE: 13.91 MB BACKUP FORMAT: tar.gz BACKUP TIMEZONE: America/New_York XLOG METHOD: fetch BACKUP CHECKSUM(s): 0 TABLESPACE(s): 3 Oid Name Location 16387 test1 /home/edb/tbl1 16388 test2 /home/edb/tbl2 16389 test3 /home/edb/tbl3 START WAL LOCATION: 000000010000000000000025 STOP WAL LOCATION: 000000010000000000000026 BACKUP METHOD: streamed BACKUP FROM: master START TIME: 2019-09-04 06:11:49 EDT STOP TIME: 2019-09-04 06:11:53 EDT TOTAL DURATION: 4 sec(s)
The following code sample displays information about the directory containing the full backup:
[edb@localhost bin]$number_of_threads> [edb@localhost bin]$ ls -l /home/edb/bkup_new/hr/ total 8 drwxrwxr-x. 3 edb edb 34 Aug 27 05:57 1566899819709 drwxrwxr-x. 3 edb edb 58 Aug 27 05:57 1566899827751 drwxrwxr-x. 3 edb edb 4096 Sep 4 06:11 1567591909098 drwxrwxr-x. 2 edb edb 4096 Sep 4 06:11 archived_wals [edb@localhost bin]$
The following code sample displays information about the creation of a full backup while streaming the transaction log. Note that the -Fp
option must be specified with the BACKUP
subcommand when streaming is used as a backup method.
[edb@localhost bin]$ ./bart BACKUP -s ACCTG -Fp INFO: DebugTarget - getVar(checkDiskSpace.bytesAvailable) INFO: new backup identifier generated 1566898964200 INFO: creating 5 harvester threads NOTICE: pg_stop_backup complete, all required WAL segments have been archived INFO: backup completed successfully INFO: BART VERSION: 2.5 BACKUP DETAILS: BACKUP STATUS: active BACKUP IDENTIFIER: 1566898964200 BACKUP NAME: none BACKUP PARENT: none BACKUP LOCATION: /home/edb/bkup_new/acctg/1566898964200 BACKUP SIZE: 46.03 MB BACKUP FORMAT: plain BACKUP TIMEZONE: US/Eastern XLOG METHOD: fetch BACKUP CHECKSUM(s): 0 TABLESPACE(s): 0 START WAL LOCATION: 000000010000000000000017 BACKUP METHOD: streamed BACKUP FROM: master START TIME: 2019-08-27 05:42:44 EDT STOP TIME: 2019-08-27 05:42:46 EDT TOTAL DURATION: 2 sec(s)
The following code sample displays the assignment of a user-defined backup name with the --backup-name
option:
[edb@localhost bin]$ ./bart BACKUP -s acctg --backup-name acctg_%year-%month-%day INFO: DebugTarget - getVar(checkDiskSpace.bytesAvailable) INFO: new backup identifier generated 1566899004804 INFO: creating 5 harvester threads NOTICE: pg_stop_backup complete, all required WAL segments have been archived INFO: backup completed successfully INFO: BART VERSION: 2.5 BACKUP DETAILS: BACKUP STATUS: active BACKUP IDENTIFIER: 1566899004804 BACKUP NAME: acctg_2019-08-27 BACKUP PARENT: none BACKUP LOCATION: /home/edb/bkup_new/acctg/1566899004804 BACKUP SIZE: 46.86 MB BACKUP FORMAT: tar BACKUP TIMEZONE: US/Eastern XLOG METHOD: fetch BACKUP CHECKSUM(s): 0 TABLESPACE(s): 0 START WAL LOCATION: 00000001000000000000001A BACKUP METHOD: streamed BACKUP FROM: master START TIME: 2019-08-27 05:43:24 EDT STOP TIME: 2019-08-27 05:43:24 EDT TOTAL DURATION: 0 sec(s)
The following code sample displays an incremental backup taken by specifying the --parent
option. The option -Fp
must be specified while taking an incremental backup as incremental backup can be taken only in plain text format.
[edb@localhost bin]$ ./bart BACKUP -s hr -Fp --parent hr_full_1 --backup-name hr_incr_1 INFO: DebugTarget - getVar(checkDiskSpace.bytesAvailable) INFO: checking /home/edb/bkup_new/hr/archived_wals for MBM files from 0/20000028 to 0/22000000 INFO: new backup identifier generated 1566899827751 INFO: creating 5 harvester threads NOTICE: all required WAL segments have been archived INFO: backup completed successfully INFO: BART VERSION: 2.5 BACKUP DETAILS: BACKUP STATUS: active BACKUP IDENTIFIER: 1566899827751 BACKUP NAME: hr_incr_1 BACKUP PARENT: 1566899819709 BACKUP LOCATION: /home/edb/bkup_new/hr/1566899827751 BACKUP SIZE: 7.19 MB BACKUP FORMAT: plain BACKUP TIMEZONE: America/New_York XLOG METHOD: fetch BACKUP CHECKSUM(s): 0 TABLESPACE(s): 0 START WAL LOCATION: 000000010000000000000022 STOP WAL LOCATION: 000000010000000000000023 BACKUP METHOD: streamed BACKUP FROM: master START TIME: 2019-08-27 05:57:07 EDT STOP TIME: 2019-08-27 05:57:08 EDT TOTAL DURATION: 1 sec(s)
The following code sample displays an incremental backup taken by specifying the --checksum-algorithm=NONE
option to skip generating checksum files.
First, the bart-scanner is started.
edb@localhost bin]$ [edb@localhost bin]$ ./bart-scanner -d --checksum-algorithm=NONE DEBUG: sockPath = /tmp/fc557c1c8853d75f1cb52a8a578f371a INFO: process created for server 'ppas11', pid = 19012 DEBUG: could not load XLogReaderLibrary at this time, archived_wals is empty
Then, an incremental backup is taken with the --checksum-algorithm=NONE
option to skip generating checksum files.
[edb@localhost bin]$ ./bart backup -s ppas11 -Fp --parent 1593506709152 --checksum-algorithm=NONE INFO: DebugTarget - getVar(checkDiskSpace.bytesAvailable) INFO: checking /home/edb/bkup/ppas11/archived_wals for MBM files from 1/D3000028 to 1/D9000000 INFO: new backup identifier generated 1593507779811 INFO: creating 5 harvester threads NOTICE: pg_stop_backup complete, all required WAL segments have been archived INFO: backup completed successfully INFO: BART VERSION: 2.6devel BACKUP DETAILS: BACKUP STATUS: active BACKUP IDENTIFIER: 1593507779811 BACKUP NAME: none BACKUP PARENT: 1593506709152 BACKUP LOCATION: /home/edb/bkup/ppas11/1593507779811 BACKUP SIZE: 7.30 MB BACKUP FORMAT: plain BACKUP TIMEZONE: US/Eastern XLOG METHOD: fetch BACKUP CHECKSUM(s): 0 TABLESPACE(s): 0 START WAL LOCATION: 0000000100000001000000D9 BACKUP METHOD: streamed BACKUP FROM: master START TIME: 2020-06-30 05:02:59 EDT STOP TIME: 2020-06-30 05:03:05 EDT TOTAL DURATION: 6 sec(s)
Note
To restore an incremental backup taken with the --checksum-algorithm=NONE
option, you must specify --disable-checksum while restoring.
Similarly, you can specify --checksum-algorithm=MD5
or --checksum-algorithm=SHA256
while taking an incremental backup if you want to generate MD5 or SHAD256 checksum files.