欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

PostgreSQL 学习实践:使用pg_rman1.3进行PG15备份恢复

最编程 2024-04-06 17:27:50
...

pg_rman 是一款用于备份和恢复 PostgreSQL 数据库的插件。其功能类似于 Oracle 的 RMAN 工具

支持以下三种备份类型:

完整备份:备份整个数据库集群。
增量备份:仅备份在同一时间线上次验证备份后修改的文件或页面。
归档 WAL备份:仅备份归档WAL文件。

部署安装:

下载地址:

  
  
  
  1. https://github.com/ossc-db/pg_rman/releases

安装:

  
  
  
  1. #上传文件至/opt

  2. cd /opt

  3. #解压文件:

  4. tar zxvf pg_rman-1.3.16-pg15.tar.gz

  5. #解压完成后:

  6. chown -R postgres.postgres /opt/pg_rman-1.3.16-pg15

  7. su - postges

  8. cd /opt/pg_rman-1.3.16-pg15

  9. make

  10. make install

  11. #安装完成后校验版本

  12. [postgres@wypg15 pg_rman-1.3.16-pg15]$ pg_rman --version

  13. pg_rman 1.3.16

  14. #安装位置

  15. [postgres@wypg15 pg_rman-1.3.16-pg15]$ which pg_rman

  16. /postgresql/pg15/bin/pg_rman

  17. #使用帮助

  18. [postgres@wypg15 pg_rman-1.3.16-pg15]$ pg_rman --help

  19. pg_rman manage backup/recovery of PostgreSQL database.

  20. Usage:

  21. pg_rman OPTION init

  22. pg_rman OPTION backup

  23. pg_rman OPTION restore

  24. pg_rman OPTION show [DATE]

  25. pg_rman OPTION show detail [DATE]

  26. pg_rman OPTION validate [DATE]

  27. pg_rman OPTION delete DATE

  28. pg_rman OPTION purge

  29. Common Options:

  30. -D, --pgdata=PATH location of the database storage area

  31. -A, --arclog-path=PATH location of archive WAL storage area

  32. -S, --srvlog-path=PATH location of server log storage area

  33. -B, --backup-path=PATH location of the backup storage area

  34. -G, --pgconf-path=PATH location of the configuration storage area

  35. -c, --check show what would have been done

  36. -v, --verbose show what detail messages

  37. -P, --progress show progress of processed files

  38. Backup options:

  39. -b, --backup-mode=MODE full, incremental, or archive

  40. -s, --with-serverlog also backup server log files

  41. -Z, --compress-data compress data backup with zlib

  42. -C, --smooth-checkpoint do smooth checkpoint before backup

  43. -F, --full-backup-on-error switch to full backup mode

  44. if pg_rman cannot find validate full backup

  45. on current timeline

  46. NOTE: this option is only used in --backup-mode=incremental or archive.

  47. --keep-data-generations=NUM keep NUM generations of full data backup

  48. --keep-data-days=NUM keep enough data backup to recover to N days ago

  49. --keep-arclog-files=NUM keep NUM of archived WAL

  50. --keep-arclog-days=DAY keep archived WAL modified in DAY days

  51. --keep-srvlog-files=NUM keep NUM of serverlogs

  52. --keep-srvlog-days=DAY keep serverlog modified in DAY days

  53. --standby-host=HOSTNAME standby host when taking backup from standby

  54. --standby-port=PORT standby port when taking backup from standby

  55. Restore options:

  56. --recovery-target-time time stamp up to which recovery will proceed

  57. --recovery-target-xid transaction ID up to which recovery will proceed

  58. --recovery-target-inclusive whether we stop just after the recovery target

  59. --recovery-target-timeline recovering into a particular timeline

  60. --recovery-target-action action the server should take once the recovery target is reached

  61. --hard-copy copying archivelog not symbolic link

  62. Catalog options:

  63. -a, --show-all show deleted backup too

  64. Delete options:

  65. -f, --force forcibly delete backup older than given DATE

  66. Connection options:

  67. -d, --dbname=DBNAME database to connect

  68. -h, --host=HOSTNAME database server host or socket directory

  69. -p, --port=PORT database server port

  70. -U, --username=USERNAME user name to connect as

  71. -w, --no-password never prompt for password

  72. -W, --password force password prompt