Taking a Backup

This section provides information about creating a full or incremental backup of a database server. For detailed information about taking a full backup, incremental backup, point-in-time recovery and restore process, see BART User Guide available at:

https://www.enterprisedb.com/edb-docs

The syntax of the BACKUP subcommand is:

bart BACKUP –s { server_name | all }
[ -F { p | t } ]
[ -z ] [ –c compression_level ]
[ --parent { backup_id | backup_name } ]
[ --backup-name backup_name ]
[ --thread-count number_of_threads ]
[ { --with-pg_basebackup | --no-pg_basebackup } ]
[ --check ]

Note

While a BACKUP subcommand is in progress, no other processes may run in parallel.

Along with the BACKUP subcommand, you can:

  • Specify the –s option and replace the server_name with the server name to be backed up (it must be configured in the BART configuration file). Specify all to take a backup of all servers. This argument is mandatory.

    The backup is saved in the backup_path/server_name/backup_id directory.

Specify the following options only if required. If you do not specify any of the following options, the backup is created using the default settings.

  • Specify the –F p option to create a backup in the plain text format and –F t to create a backup in tar format (default). If the transaction log streaming method is used, then the -F p option must be specified.
  • Specify the –z option to use gzip compression on the tar file output using the default compression level. This option is applicable only for the tar format.
  • Specify the –c option to apply the gzip compression level on the tar file output, and replace compression_level with the digit 1 through 9, with 9 being the best compression (applicable only for the tar format).
  • If you want to take an incremental backup, specify the option --parent and replace backup_id with the backup identifier of a parent backup or replace backup_name with the parent backup name. Incremental backup can only be taken in the plain text format (–F p). Specify the option --check before taking an incremental backup to verify if the required MBM files are present in the BART backup catalog. The --parent option must be specified when the --check option is used.
  • Specify the option --backup-name and replace backup_name with the user-friendly name assigned to the backup.
  • Specify the option –thread count and replace number_of_threads with the number of worker threads to run in parallel to copy blocks for incremental backups
  • Specify the option --with-pg_basebackup to use 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.

Note

If the thread count in effect is greater than 1, then the pg_basebackup utility is not used to take the full backup unless the --with-pg_basebackup option is specified with the BACKUP subcommand.

  • Specify the option --no pg_basebackup to not use pg_basebackup to take a full backup.

The following example creates a full backup in the default tar format with gzip compression. 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
/home/edb/bkup_new/hr/1567591909098
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 example shows an incremental backup taken by specifying the --parent option. The option -F p must be specified as well for plain text format.

[edb@localhost bin]$ ./bart BACKUP -s hr -F p --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)