Crunchy PostgreSQL database backup via pgo command

zchbaby2000發表於2023-02-16

pgo使得Crunchy Postgresql的管理極為方便,可惜目前支援的命令不太多。但是有幾個關鍵的操作比如備份,恢復pgo命令還是支援的。

安裝非常簡單,詳情見下面的連結

Install pgo from https://access.crunchydata.com/documentation/postgres-operator-client/latest/


在測試命令之前,先在openshift上安裝Crunchy Postgres Operator和一個postgrescluster

namespace: project-demo

postgrescluster: demo


Check version information

➜  ~ oc pgo -n project-demo version
Client Version: v0.2.0
Operator Version: v5.2.0


Show database backup information

➜  ~ oc pgo show backup demo
stanza: db
    status: ok
    cipher: none
    db (current)
        wal archive min/max (14): 000000010000000000000001/000000010000000000000005
        full backup: 20230216-012002F
            timestamp start/stop: 2023-02-16 01:20:02 / 2023-02-16 01:21:15
            wal start/stop: 000000010000000000000004 / 000000010000000000000004
            database size: 36.4MB, database backup size: 36.4MB
            repo1: backup set size: 4.5MB, backup size: 4.5MB
➜  ~

Run a full backup

➜  ~ oc pgo -n project-demo backup demo --repoName=repo1 --options="--type=full"
postgresclusters/demo backup initiated

Show all backup

➜  ~ oc pgo show backup demo
stanza: db
    status: ok
    cipher: none
    db (current)
        wal archive min/max (14): 000000010000000000000001/000000010000000000000007
        full backup: 20230216-012002F
            timestamp start/stop: 2023-02-16 01:20:02 / 2023-02-16 01:21:15
            wal start/stop: 000000010000000000000004 / 000000010000000000000004
            database size: 36.4MB, database backup size: 36.4MB
            repo1: backup set size: 4.5MB, backup size: 4.5MB
        full backup: 20230216-013037F
            timestamp start/stop: 2023-02-16 01:30:37 / 2023-02-16 01:30:49
            wal start/stop: 000000010000000000000007 / 000000010000000000000007
            database size: 37.1MB, database backup size: 37.1MB
            repo1: backup set size: 4.5MB, backup size: 4.5MB
➜  ~

Run a differential backup

➜  ~ oc pgo -n project-demo backup demo --repoName=repo1 --options="--type=diff"
postgresclusters/demo backup initiated

Show all backup

➜  ~ oc pgo show backup demo
stanza: db
    status: ok
    cipher: none
    db (current)
        wal archive min/max (14): 000000010000000000000001/00000001000000000000000A
        full backup: 20230216-012002F
            timestamp start/stop: 2023-02-16 01:20:02 / 2023-02-16 01:21:15
            wal start/stop: 000000010000000000000004 / 000000010000000000000004
            database size: 36.4MB, database backup size: 36.4MB
            repo1: backup set size: 4.5MB, backup size: 4.5MB
        full backup: 20230216-013037F
            timestamp start/stop: 2023-02-16 01:30:37 / 2023-02-16 01:30:49
            wal start/stop: 000000010000000000000007 / 000000010000000000000007
            database size: 37.1MB, database backup size: 37.1MB
            repo1: backup set size: 4.5MB, backup size: 4.5MB
        diff backup: 20230216-013037F_20230216-013645D
            timestamp start/stop: 2023-02-16 01:36:45 / 2023-02-16 01:36:48
            wal start/stop: 000000010000000000000009 / 00000001000000000000000A
            database size: 37.6MB, database backup size: 4.4MB
            repo1: backup set size: 4.5MB, backup size: 400.3KB
            backup reference list: 20230216-013037F
➜  ~

Run an incremental backup

➜  ~ oc pgo -n project-demo backup demo --repoName=repo1 --options="--type=incr"
postgresclusters/demo backup initiated


Show all backup

➜  ~ oc pgo show backup demo
stanza: db
    status: ok
    cipher: none
    db (current)
        wal archive min/max (14): 000000010000000000000001/00000001000000000000000D
        full backup: 20230216-012002F
            timestamp start/stop: 2023-02-16 01:20:02 / 2023-02-16 01:21:15
            wal start/stop: 000000010000000000000004 / 000000010000000000000004
            database size: 36.4MB, database backup size: 36.4MB
            repo1: backup set size: 4.5MB, backup size: 4.5MB
        full backup: 20230216-013037F
            timestamp start/stop: 2023-02-16 01:30:37 / 2023-02-16 01:30:49
            wal start/stop: 000000010000000000000007 / 000000010000000000000007
            database size: 37.1MB, database backup size: 37.1MB
            repo1: backup set size: 4.5MB, backup size: 4.5MB
        diff backup: 20230216-013037F_20230216-013645D
            timestamp start/stop: 2023-02-16 01:36:45 / 2023-02-16 01:36:48
            wal start/stop: 000000010000000000000009 / 00000001000000000000000A
            database size: 37.6MB, database backup size: 4.4MB
            repo1: backup set size: 4.5MB, backup size: 400.3KB
            backup reference list: 20230216-013037F
        incr backup: 20230216-013037F_20230216-014148I
            timestamp start/stop: 2023-02-16 01:41:48 / 2023-02-16 01:41:50
            wal start/stop: 00000001000000000000000C / 00000001000000000000000D
            database size: 38MB, database backup size: 2MB
            repo1: backup set size: 4.5MB, backup size: 99.9KB
            backup reference list: 20230216-013037F, 20230216-013037F_20230216-013645D
➜  ~



來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/725820/viewspace-2935651/,如需轉載,請註明出處,否則將追究法律責任。

相關文章