Optional: removing stale backups

If you have large databases and want to better optimize your disk space usage, you can remove a stale backup.

About this task

When you do the first swap (this applies only to the first swap) of receiver and master after upgrade, on the new master (the old receiver), the existing full backup of the original Postgres v12 database is redundant. You can remove this backup to save disk space.

CAUTION:
Never remove a backup unless you are sure you will not need to restore it.

Procedure

  1. To look at the backups, list them on the new master (the old receiver) using the following command. The stanza name is ibm-security-soar by default. Enter your stanza name if it is different:
    sudo -u postgres pgbackrest --stanza=ibm-security-soar info
    When you run this command after the first swap, the output looks similar to the following:
    -bash-4.2$ sudo -u postgres pgbackrest info
    stanza: ibm-security-soar
        status: ok
        cipher: none
    
        db (prior)
            wal archive min/max (9.6): 000000010000000000000002/000000010000000000000015
    
            full backup: 20211115-030233F
                timestamp start/stop: 2021-11-15 11:02:33 / 2021-11-15 11:02:38
                wal start/stop: 000000010000000000000004 / 000000010000000000000004
                database size: 75.2MB, database backup size: 75.2MB
                repo1: backup set size: 8.7MB, backup size: 8.7MB
    
            incr backup: 20211115-030233F_20211116-000102I
                timestamp start/stop: 2021-11-16 00:01:02 / 2021-11-16 00:01:08
                wal start/stop: 00000001000000000000000A / 00000001000000000000000A
                database size: 79.6MB, database backup size: 19.9MB
                repo1: backup set size: 9MB, backup size: 2.5MB
                backup reference list: 20211115-030233F
    
            incr backup: 20211115-030233F_20211117-000101I
                timestamp start/stop: 2021-11-17 00:01:01 / 2021-11-17 00:01:04
                wal start/stop: 00000001000000000000000E / 00000001000000000000000E
                database size: 80.1MB, database backup size: 2.0MB
                repo1: backup set size: 9.1MB, backup size: 293.0KB
                backup reference list: 20211115-030233F, 20211115-030233F_20211116-000102I
    
            incr backup: 20211115-030233F_20211117-200608I
                timestamp start/stop: 2021-11-17 20:06:08 / 2021-11-17 20:06:12
                wal start/stop: 000000010000000000000012 / 000000010000000000000012
                database size: 80.6MB, database backup size: 2.4MB
                repo1: backup set size: 9.1MB, backup size: 311.2KB
                backup reference list: 20211115-030233F, 20211115-030233F_20211116-000102I, 20211115-030233F_20211117-000101I
    
        db (prior)
            wal archive min/max (12): 00000001000000000000001C/000000010000000000000025
    
            full backup: 20211117-200903F
                timestamp start/stop: 2021-11-17 20:09:03 / 2021-11-17 20:09:07
                wal start/stop: 00000001000000000000001E / 00000001000000000000001E
                database size: 85.8MB, database backup size: 85.8MB
                repo1: backup set size: 9.8MB, backup size: 9.8MB
    
        db (current)
            wal archive min/max (12): 000000010000000000000029/000000020000000000000037
    
            full backup: 20211118-161704F
                timestamp start/stop: 2021-11-18 16:17:04 / 2021-11-18 16:17:15
                wal start/stop: 000000020000000000000037 / 000000020000000000000037
                database size: 92.4MB, database backup size: 92.4MB
                repo1: backup set size: 10MB, backup size: 10MB

    In this example, there are two database entries for Postgres 12 wal archive min/max (12). One is listed as db (prior) and the other as db (current).

    The full backup under the db (prior) for Postgres 12 wal archive min/max (12) is a stale backup from the previous (pre-DR) database, which you can delete.

    So in this example, the backup to delete is full backup: 20211117-200903F. However, by deleting this backup, it is not possible to restore the database to the previous pre-DR Postgres v12 state.

  2. To delete a full backup, there must be at least two full backup sets. Deleting a full backup also deletes its incremental backups. To remove the backup, use the following command:
    sudo resExpireBackup <backup_set_name>
    For the example above, the command to remove the backup is:
    sudo resExpireBackup 20211117-200903F