BACKUP v2.6

The BACKUP subcommand is used to create a full backup or an incremental backup.

Syntax for 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 } ]
Note

While taking a backup, if a file (for example, database server log file) exceeding 1 GB size is stored in the $PGDATA directory, the backup will fail. To avoid such backup failure, you need to store large files (exceeding 1 GB) outside the $PGDATA directory.

Syntax for incremental Backup:

bart BACKUP –s { <server_name> | all } [ -F p]
 [ --parent { <backup_id> | <backup_name> } ]
  [ --backup-name <backup_name> ]
  [ --thread-count <number_of_threads> ]
  [ --check ]
  [--checksum-algorithm ]
Note

To take an incremental backup, you must take a full backup first followed by incremental backup.

Please Note:

  • While a BACKUP subcommand is in progress, no other subcommands must be invoked. Any subcommands invoked while a backup is in progress will skip and ignore the backups.

  • For full backup, the target default format is a tar file, whereas for incremental backup, only plain format must be specified.

  • The backup is saved in the <backup_path>/<server_name>/<backup_id> directory, where <backup_path> is the value assigned to the <backup_path> parameter in the BART configuration file, <server_name> is the lowercase name of the database server as listed in the configuration file, and <backup_id> is a backup identifier assigned by BART to the particular backup.

  • MD5 checksums of the full backup and any user-defined tablespaces are saved as well for tar backups.

  • Before performing the backup, BART checks to ensure if there is enough disk space to completely store the backup in the BART backup catalog.

  • In the postgresql.conf file, ensure the wal_keep_segments configuration parameter is set to a sufficiently large value. A low setting of the wal_keep_segments configuration parameter may result in the deletion of some WAL files before the BART BACKUP subcommand saves them to the archive_path. For information about the wal_keep_segments parameter, see the PostgreSQL Core Documentation.

  • In the BART configuration file, setting xlog_method=stream will instruct the server to stream the transaction log in parallel with creation of the backup for a specific database server; otherwise the transaction log files are collected upon completion of the backup. See the EDB Backup and Recovery Installation and Upgrade Guide available at the EDB website for details about database server setting.

    Note

    If the transaction log streaming method is used, the -Fp option for a plain text backup format must be specified with the BACKUP subcommand.

  • When you use BART to take a backup of PostgreSQL server, multiple backups can be taken simultaneously and if a backup is interrupted, the backup mode is terminated automatically without the need to run pg_stop_backup() command manually to terminate the backup.

Options

Along with the BACKUP subcommand, specify the following option:

OptionsDescription
-s { server_name | all }
--server { server_name | all }
server_name is the database server name to be backed up as specified in the BART configuration file. If all is specified, all servers are backed up. This option is mandatory.
If all is specified, and a connection to a database server listed in the BART configuration file cannot be opened, the backup for that database server is skipped, but the backup operation continues for the other database servers.

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

OptionsDescription
-F { p | t }
--format { p | t }
Specify this option to provide the backup file format. Use p for plain text or t for tar. If the option is omitted, the default is tar format.
For taking incremental backups, the option -Fp must be specified.
-z
--gzip
This is applicable only for full backup. Specify this option to use gzip compression on the tar file output using the default compression level. This option is applicable only for the tar format.
-c <compression_level>
--compress-level <compression_level>
This is applicable only for full backup. Specify this option to use the gzip compression level on the tar file output. compression_level is a digit from 1 through 9, with 9 being the best compression. This option is applicable only for the tar format.
--parent { backup_id | backup_name }Specify this option to take an incremental backup. <backup_id> is the backup identifier of a parent backup. <backup_name> is the user-defined alphanumeric name of a parent backup.
The parent is a backup taken prior to the incremental backup. The parent backup can be either a full backup or an incremental backup.
The option –Fp must be specified since an incremental backup can only be taken in plain text format.
An incremental backup cannot be taken on a standby database server. See Block-Level Incremental Backup for additional information on incremental backups.
--backup-name <backup_name>Specify this option to assign a user-defined, alphanumeric friendly name to the backup. The maximum permitted length of backup name is 49 characters.
The backup name may include the following variables to be substituted by the timestamp values when the backup is taken: 1) %year – 4-digit year, 2) %month – 2-digit month, 3) %day – 2-digit day, 4) %hour 2-digit hour, 5) %minute – 2-digit minute, and 6) %second – 2-digit second.
To include the percent sign (%) as a character in the backup name, specify %% in the alphanumeric string.
If the backup name contains space characters (i.e. more than one word) or when referenced with the option -i by other subcommands (such as restore), enclose the string in single quotes or double quotes. See backup name examples.
If the --backup-name option 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 use the number of worker threads to run in parallel to copy blocks for a backup.
If the option --thread-count is omitted, then the thread_count parameter in the BART configuration file applicable to this database server is used.
If the option --thread-count is not enabled for this database server, then the thread_count setting in the global section of the BART configuration file is used.
If the option --thread-count is not set in the global section as well, the default number of threads is 1.
If parallel backup is run with N number of worker threads, then it will initiate N+ 1 concurrent connections with the server.
Thread count will not be effective if backup is taken on a standby server.
For more information about the --thread-count parameter, see the EDB Backup and Recovery Installation and Upgrade Guide available at the EDB website
--with-pg_basebackupThis is applicable only for full backup. Specify this option 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.
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 option --with-pg_basebackup is specified with the BACKUP subcommand.
--no-pg_basebackupThis is applicable only for full backup. Specify this option if you do not want pg_basebackup 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 option --no-pg_basebackup is specified with the BACKUP subcommand.
--checkThis is applicable only for incremental backup. Specify this option to verify if the required MBM files are present in the archived_wals directory as specified in the archive_path parameter in the bart.cfg file before taking an incremental backup. The option --parent must be specified when the option --check is used. An actual incremental backup is not taken when the option --check is specified.
--checksum-algorithmWhile 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.

Backup Name Examples

The following examples demonstrate using the --backup-name clause:

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

Error messages

The following table lists the error messages that may be encountered when using the BACKUP subcommand:

error messageCause
edb@localhost bin]$ ./bart backup -s mktg -Ft

WARNING: xlog_method is empty, defaulting to global policy

ERROR: backup failed for server 'mktg'

free disk space is not enough to backup the server 'mktg'

space available 13.35 GB, approximately required 14.65 GB
Insufficient free disk space.
ERROR: backup failed for server 'mktg'

command failed with exit code 1

pg_basebackup: could not get transaction log end position from server: ERROR: requested WAL segment 00000001000000D50000006B has already been removed
The wal_keep_segments configuration parameter is not set to a sufficiently large value in the postgresql.conf file.
ERROR: backup failed for server 'mktg'

connection to the server failed: could not connect to server: Connection refused

Is the server running on host "172.16.114.132" and accepting

TCP/IP connections on port 5444?
A connection to a database server listed in the BART configuration file fails. As a result the backup for that database server is skipped, but the backup operation continues for other database servers