pg_probackup备份

可以使用pg_probackup --help查看帮助

pg_probackup --help

pg_probackup - utility to manage backup/recovery of PostgreSQL database.

  pg_probackup help [COMMAND]

  pg_probackup version

  pg_probackup init -B backup-path  初始化备份路径

  pg_probackup set-config -B backup-path --instance=instance_name  set-config配置备份  -B backup-path 配置备份路径  --instance=instance_name 配置备份实例名
                 [-D pgdata-path]   数据所在路径
                 [--external-dirs=external-directories-paths] 如果需要备份到外部,外部路径
                 [--log-level-console=log-level-console] 
                 [--log-level-file=log-level-file]
                 [--log-filename=log-filename]
                 [--error-log-filename=error-log-filename]
                 [--log-directory=log-directory]
                 [--log-rotation-size=log-rotation-size] 日志轮转大小
                 [--log-rotation-age=log-rotation-age] 日志轮转时间
                 [--retention-redundancy=retention-redundancy]  冗余策略
                 [--retention-window=retention-window]  保留时间
                 [--wal-depth=wal-depth]  
                 [--compress-algorithm=compress-algorithm]  压缩算法
                 [--compress-level=compress-level]  压缩级别
                 [--archive-timeout=timeout]  如果数据库很少有业务操作,产生的wal比较少,设置归档超时时间可以在超过该时间之后,立即归档一个
                 [-d dbname] [-h host] [-p port] [-U username] 数据库名,主机,端口,用户名
                 [--remote-proto] [--remote-host] 远程协议,主机,端口,路径,用户
                 [--remote-port] [--remote-path] [--remote-user]
                 [--ssh-options]
                 [--restore-command=cmdline] [--archive-host=destination]
                 [--archive-port=port] [--archive-user=username]
                 [--help]

  pg_probackup set-backup -B backup-path --instance=instance_name
                 -i backup-id [--ttl=interval] [--expire-time=timestamp]
                 [--note=text]
                 [--help]

  pg_probackup show-config -B backup-path --instance=instance_name
                 [--format=format]
                 [--help]

  pg_probackup backup -B backup-path -b backup-mode --instance=instance_name
                 [-D pgdata-path] [-C]
                 [--stream [-S slot-name]] [--temp-slot]
                 [--backup-pg-log] [-j num-threads] [--progress]
                 [--no-validate] [--skip-block-validation]
                 [--external-dirs=external-directories-paths]
                 [--no-sync]
                 [--log-level-console=log-level-console]
                 [--log-level-file=log-level-file]
                 [--log-filename=log-filename]
                 [--error-log-filename=error-log-filename]
                 [--log-directory=log-directory]
                 [--log-rotation-size=log-rotation-size]
                 [--log-rotation-age=log-rotation-age]
                 [--delete-expired] [--delete-wal] [--merge-expired]
                 [--retention-redundancy=retention-redundancy]
                 [--retention-window=retention-window]
                 [--wal-depth=wal-depth]
                 [--compress]
                 [--compress-algorithm=compress-algorithm]
                 [--compress-level=compress-level]
                 [--archive-timeout=archive-timeout]
                 [-d dbname] [-h host] [-p port] [-U username]
                 [-w --no-password] [-W --password]
                 [--remote-proto] [--remote-host]
                 [--remote-port] [--remote-path] [--remote-user]
                 [--ssh-options]
                 [--ttl=interval] [--expire-time=timestamp] [--note=text]
                 [--help]

  pg_probackup restore -B backup-path --instance=instance_name
                 [-D pgdata-path] [-i backup-id] [-j num-threads]
                 [--recovery-target-time=time|--recovery-target-xid=xid
                  |--recovery-target-lsn=lsn [--recovery-target-inclusive=boolean]]
                 [--recovery-target-timeline=timeline]
                 [--recovery-target=immediate|latest]
                 [--recovery-target-name=target-name]
                 [--recovery-target-action=pause|promote|shutdown]
                 [--restore-command=cmdline]
                 [-R | --restore-as-replica] [--force]
                 [--primary-conninfo=primary_conninfo]
                 [-S | --primary-slot-name=slotname]
                 [--no-validate] [--skip-block-validation]
                 [-T OLDDIR=NEWDIR] [--progress]
                 [--external-mapping=OLDDIR=NEWDIR]
                 [--skip-external-dirs] [--no-sync]
                 [-I | --incremental-mode=none|checksum|lsn]
                 [--db-include | --db-exclude]
                 [--remote-proto] [--remote-host]
                 [--remote-port] [--remote-path] [--remote-user]
                 [--ssh-options]
                 [--archive-host=hostname]
                 [--archive-port=port] [--archive-user=username]
                 [--help]

  pg_probackup validate -B backup-path [--instance=instance_name]
                 [-i backup-id] [--progress] [-j num-threads]
                 [--recovery-target-time=time|--recovery-target-xid=xid
                  |--recovery-target-lsn=lsn [--recovery-target-inclusive=boolean]]
                 [--recovery-target-timeline=timeline]
                 [--recovery-target-name=target-name]
                 [--skip-block-validation]
                 [--help]

  pg_probackup checkdb [-B backup-path] [--instance=instance_name]
                 [-D pgdata-path] [--progress] [-j num-threads]
                 [--amcheck] [--skip-block-validation]
                 [--heapallindexed]
                 [--help]

  pg_probackup show -B backup-path
                 [--instance=instance_name [-i backup-id]]
                 [--format=format] [--archive]
                 [--help]

  pg_probackup delete -B backup-path --instance=instance_name
                 [-j num-threads] [--progress]
                 [--retention-redundancy=retention-redundancy]
                 [--retention-window=retention-window]
                 [--wal-depth=wal-depth]
                 [-i backup-id | --delete-expired | --merge-expired | --status=backup_status]
                 [--delete-wal]
                 [--dry-run]
                 [--help]

  pg_probackup merge -B backup-path --instance=instance_name
                 -i backup-id [--progress] [-j num-threads]
                 [--help]

  pg_probackup add-instance -B backup-path -D pgdata-path
                 --instance=instance_name
                 [--external-dirs=external-directories-paths]
                 [--remote-proto] [--remote-host]
                 [--remote-port] [--remote-path] [--remote-user]
                 [--ssh-options]
                 [--help]

  pg_probackup del-instance -B backup-path
                 --instance=instance_name
                 [--help]

  pg_probackup archive-push -B backup-path --instance=instance_name
                 --wal-file-name=wal-file-name
                 [-j num-threads] [--batch-size=batch_size]
                 [--archive-timeout=timeout]
                 [--no-ready-rename] [--no-sync]
                 [--overwrite] [--compress]
                 [--compress-algorithm=compress-algorithm]
                 [--compress-level=compress-level]
                 [--remote-proto] [--remote-host]
                 [--remote-port] [--remote-path] [--remote-user]
                 [--ssh-options]
                 [--help]

  pg_probackup archive-get -B backup-path --instance=instance_name
                 --wal-file-path=wal-file-path
                 --wal-file-name=wal-file-name
                 [-j num-threads] [--batch-size=batch_size]
                 [--no-validate-wal]
                 [--remote-proto] [--remote-host]
                 [--remote-port] [--remote-path] [--remote-user]
                 [--ssh-options]
                 [--help]

具体的帮助信息可以使用如下方法查看
比如查看set-config的帮助
pg_probackup set-config --help

常用pg_probackup命令

查看备份
pg_probackup show -B /backup --instance backup_test
删除备份实例
pg_probackup delete-instance -B /backup --instance backup_test
删除备份
pg_probackup delete -B /backup --instance backup_test -i REH7AO REH78Q REH76U REH738 REH6YH REH6Y0

验证备份
pg_probackup validate -B /backup
检查备份文件
pg_probackup checkdb /backup
添加备份实例
//bin/pg_probackup add-instance -B /backup/ -D /data/ --instance backup_test
全备命令
pg_probackup backup -B /backup --instance backup_test -U -W -b full -j 2
增备命令
pg_probackup backup -B /backup --instance backup_test -U -W -b page -j 2

合并全备和增备

pg_probackup merge -B /vastbase/atlasdb/backup  --instance backup_test -i REKUJ7 REKUET
INFO: Merge started
INFO: Merging backup REKUJ7 with parent chain
INFO: Validate parent chain for backup REKUJ7
INFO: Validating backup REKUET
INFO: Backup REKUET data files are valid
INFO: Validating backup REKUJ7
INFO: Backup REKUJ7 data files are valid
INFO: Start merging backup files
INFO: Backup files are successfully merged, time elapsed: 0
INFO: Delete: REKUJ7 2022-07-06 10:21:15+08
INFO: Rename merged full backup REKUET to REKUJ7
INFO: Validating backup REKUJ7
INFO: Backup REKUJ7 data files are valid
INFO: Merge of backup REKUJ7 completed
posted @ 2022-07-06 11:31  南大仙  阅读(395)  评论(0)    收藏  举报