Get Postgres Tips and Tricks
Subscribe to get advanced Postgres how-tos.
MANAGE¶
The MANAGE
subcommand can be invoked to:
- Evaluate backups, mark their status, and delete obsolete backups
based on the
retention_policy
parameter in the BART configuration file. - Compress the archived WAL files based on the
wal_compression
parameter in the BART configuration file.
Syntax:
bart MANAGE [ –s { <server_name> | all} ] [ -l ] [ -d ] [ -c { keep | nokeep } -i { <backup_id> | <backup_name> | all } ] [ -n ]
To view detailed information about the MANAGE
subcommand and retention
policy management, see the EDB Postgres Backup and Recovery User
Guide. For information about setting the wal_compression
parameter,
see the EDB Postgres Backup and Recovery Installation and Upgrade
Guide. These guides are available at:
Options
-s [ <server_name> | all ]
or--server [ <server_name> | all ]
<server_name>
is the name of the database server to which theMANAGE
actions are to be applied.- If
all
is specified or if the-s
option is omitted, actions are applied to all database servers.
-l
or--list-obsolete
Lists the backups marked as obsolete.
-d
or--delete-obsolete
Deletes the backups marked as obsolete. This action physically deletes the backup along with its archived WAL files and any MBM files for incremental backups.
-c { keep | nokeep }
or--change-status { keep | nokeep }
- Specify
keep
to change the backup status tokeep
to retain the backup indefinitely. - Specify
nokeep
to change the backup status back toactive
. You can then re-evaluate and possibly mark the backup asobsolete
(according to the retention policy) using theMANAGE
subcommand.
- Specify
Note
The –c
option can only be used with the -i
option.
-i { <backup_id> | <backup_name> | all
} or--backupid { <backup_id> | <backup_name> | all
}<backup_id>
is a backup identifier and<backup_name>
is the user-defined alphanumeric name for the backup.- If
all
is specified, actions are applied to all backups. - The
-i
option can only be used with the-c
option.
-n, --dry-run
Performs the test run and displays the results prior to actually implementing the actions as if the operation was performed, however, no changes are actually made.
- If you specify
-n
with the-d
option, it displays which backups would be deleted, but does not actually delete the backups. - If you specify
-n
with the-c
option, it displays the keep or nokeep action, but does not actually change the backup status. - If you specify
-n
alone with no other options or if you specify-n
with only the-s
option, it displays which active backups would be marked as obsolete, but does not actually change the backup status. In addition, no compression is performed on uncompressed, archived WAL files even if WAL compression is enabled for the database server.
- If you specify
Example
The following example performs a dry run for the specified database server displaying which active backups are evaluated as obsolete according to the retention policy, but does not actually change the backup status:
-bash-4.2$ bart MANAGE -s acctg -n
INFO: processing server 'acctg', backup '1482770807519'
INFO: processing server 'acctg', backup '1482770803000'
INFO: marking backup '1482770803000' as obsolete
INFO: 1 WAL file(s) marked obsolete
INFO: processing server 'acctg', backup '1482770735155'
INFO: marking backup '1482770735155' as obsolete
INFO: 2 incremental(s) of backup '1482770735155' will be marked obsolete
INFO: marking incremental backup '1482770780423' as obsolete
INFO: marking incremental backup '1482770763227' as obsolete
INFO: 3 WAL file(s) marked obsolete
INFO: 1 Unused WAL file(s) present
INFO: 2 Unused file(s) (WALs included) present, use 'MANAGE -l' for the
list
The following example marks active backups as obsolete according to the retention policy for the specified database server:
-bash-4.2$ bart MANAGE -s acctg
INFO: processing server 'acctg', backup '1482770807519'
INFO: processing server 'acctg', backup '1482770803000'
INFO: marking backup '1482770803000' as obsolete
INFO: 1 WAL file(s) marked obsolete
INFO: processing server 'acctg', backup '1482770735155'
INFO: marking backup '1482770735155' as obsolete
INFO: 2 incremental(s) of backup '1482770735155' will be marked obsolete
INFO: marking incremental backup '1482770780423' as obsolete
INFO: marking incremental backup '1482770763227' as obsolete
INFO: 3 WAL file(s) marked obsolete
INFO: 1 Unused WAL file(s) present
INFO: 2 Unused file(s) (WALs included) present, use 'MANAGE -l' for the
list
The following example lists backups marked as obsolete for the specified database server:
-bash-4.2$ bart MANAGE -s acctg -l
SERVER NAME: acctg
BACKUP ID: 1482770803000
BACKUP STATUS: obsolete
BACKUP TIME: 2016-12-26 11:46:43 EST
BACKUP SIZE: 59.52 MB
WAL FILE(s): 1
WAL FILE: 000000010000000100000055
SERVER NAME: acctg
BACKUP ID: 1482770735155
BACKUP STATUS: obsolete
BACKUP TIME: 2016-12-26 11:45:35 EST
BACKUP SIZE: 59.52 MB
INCREMENTAL BACKUP(s): 2
BACKUP ID: 1482770780423
BACKUP PARENT: 1482770735155
BACKUP STATUS: obsolete
BACKUP TIME: 2016-12-26 11:45:35 EST
BACKUP SIZE: 59.52 MB
BACKUP ID: 1482770763227
BACKUP PARENT: 1482770735155
BACKUP STATUS: obsolete
BACKUP TIME: 2016-12-26 11:45:35 EST
BACKUP SIZE: 59.52 MB
WAL FILE(s): 3
WAL FILE: 000000010000000100000054
WAL FILE: 000000010000000100000053
WAL FILE: 000000010000000100000052
UNUSED FILE(s): 2
UNUSED FILE: 000000010000000100000051
UNUSED FILE: 0000000100000001510000280000000152000000.mbm
The following example deletes the obsolete backups for the specified database server:
-bash-4.2$ bart MANAGE -s acctg -d
INFO: removing all obsolete backups of server 'acctg'
INFO: removing obsolete backup '1482770803000'
INFO: 1 WAL file(s) will be removed
INFO: removing WAL file '000000010000000100000055'
INFO: removing obsolete backup '1482770735155'
INFO: 3 WAL file(s) will be removed
INFO: 2 incremental(s) of backup '1482770735155' will be removed
INFO: removing obsolete incremental backup '1482770780423'
INFO: removing obsolete incremental backup '1482770763227'
INFO: removing WAL file '000000010000000100000054'
INFO: removing WAL file '000000010000000100000053'
INFO: removing WAL file '000000010000000100000052'
INFO: 8 Unused file(s) will be removed
INFO: removing (unused) file '000000010000000100000056.00000028.backup'
INFO: removing (unused) file '000000010000000100000056'
INFO: removing (unused) file '000000010000000100000055.00000028.backup'
INFO: removing (unused) file '000000010000000100000054.00000028.backup'
INFO: removing (unused) file '000000010000000100000053.00000028.backup'
INFO: removing (unused) file '000000010000000100000052.00000028.backup'
INFO: removing (unused) file '000000010000000100000051'
INFO: removing (unused) file
'0000000100000001510000280000000152000000.mbm'
The following example changes the specified backup to keep status to retain it indefinitely:
-bash-4.2$ bart MANAGE -s acctg -c keep -i 1482770807519
INFO: changing status of backup '1482770807519' of server 'acctg' from
'active' to 'keep'
INFO: 1 WAL file(s) changed
-bash-4.2$ bart SHOW-BACKUPS -s acctg -i 1482770807519 -t
SERVER NAME : acctg
BACKUP ID : 1482770807519
BACKUP NAME : none
BACKUP PARENT : none
BACKUP STATUS : keep
BACKUP TIME : 2016-12-26 11:46:47 EST
BACKUP SIZE : 59.52 MB
WAL(S) SIZE : 16.00 MB
NO. OF WALS : 1
FIRST WAL FILE : 000000010000000100000057
CREATION TIME : 2016-12-26 11:52:47 EST
LAST WAL FILE : 000000010000000100000057
CREATION TIME : 2016-12-26 11:52:47 EST
The following example resets the specified backup to active status:
-bash-4.2$ bart MANAGE -s acctg -c nokeep -i 1482770807519
INFO: changing status of backup '1482770807519' of server 'acctg' from
'keep' to 'active'
INFO: 1 WAL file(s) changed
-bash-4.2$ bart SHOW-BACKUPS -s acctg -i 1482770807519 -t
SERVER NAME : acctg
BACKUP ID : 1482770807519
BACKUP NAME : none
BACKUP PARENT : none
BACKUP STATUS : active
BACKUP TIME : 2016-12-26 11:46:47 EST
BACKUP SIZE : 59.52 MB
WAL(S) SIZE : 16.00 MB
NO. OF WALS : 1
FIRST WAL FILE : 000000010000000100000057
CREATION TIME : 2016-12-26 11:52:47 EST
LAST WAL FILE : 000000010000000100000057
CREATION TIME : 2016-12-26 11:52:47 EST
The following example uses the enabled wal_compression
parameter in the
BART configuration file as shown by the following:
[ACCTG]
host = 127.0.0.1
port = 5445
user = enterprisedb
cluster_owner = enterprisedb
allow_incremental_backups = disabled
wal_compression = enabled
description = "Accounting"
When the MANAGE
subcommand is invoked, the following message is
displayed indicating that WAL file compression is performed:
-bash-4.2$ bart MANAGE -s acctg
INFO: 4 WAL file(s) compressed
WARNING: 'retention_policy' is not set for server 'acctg'
The following example shows the archived WAL files in compressed format:
-bash-4.2$ pwd
/opt/backup/acctg
-bash-4.2$ ls -l archived_wals
total 160
-rw------- 1 enterprisedb enterprisedb 27089 Dec 26 12:16
00000001000000010000005B.gz
-rw------- 1 enterprisedb enterprisedb 305 Dec 26 12:17
00000001000000010000005C.00000028.backup
-rw------- 1 enterprisedb enterprisedb 27112 Dec 26 12:17
00000001000000010000005C.gz
-rw------- 1 enterprisedb enterprisedb 65995 Dec 26 12:18
00000001000000010000005D.gz
-rw------- 1 enterprisedb enterprisedb 305 Dec 26 12:18
00000001000000010000005E.00000028.backup
-rw------- 1 enterprisedb enterprisedb 27117 Dec 26 12:18
00000001000000010000005E.gz