ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

040.PGSQL-备份和恢复-增量备份-创建基础备份

2021-07-28 18:31:45  阅读:298  来源: 互联网

标签:pgsql 13 -- 备份 PGSQL pg 040 backup basebackup


增量备份-创建基础备份

使用pg_basebackup 创建基础备份

[postgres@s101 /usr/pgsql-13/bin]$

pg_basebackup

 

设置配置文件pg_hba.conf,添加连接信息,否则会报错

 

 

[postgres@s101 /usr/pgsql-13/bin]$/usr/pgsql-13/bin/pg_basebackup   -D /var/lib/pgsql/13/backups  -Ft  -Pv  -Xf  -z  -Z5  -h 192.168.17.101 -U postgres  -p 5432
pg_basebackup: error: FATAL:  no pg_hba.conf entry for replication connection from host "192.168.17.101", user "postgres", SSL off

 

[root@s101 /var/lib/pgsql/13/data]#nano pg_hba.conf

# Allow replication connections from localhost, by a user with the
# replication privilege.
host replication postgres 192.168.17.101/32 trust

 

重启数据库

[root@s101 /var/lib/pgsql/13/data]#sudo systemctl restart postgresql-13

 

使用pg_basebackup 创建基础备份

/usr/pgsql-13/bin/pg_basebackup   -D /var/lib/pgsql/13/backups  -Ft  -Pv  -Xf  -z  -Z5  -h 192.168.17.101 -U postgres  -p 5432
-D
-F
-P
-v
-X
-z, --gzip compress tar output 使用gzip压缩,仅能能与tar输出模式配合使用
-Z, --compress=0-9     compress tar output with given compression level   指定压缩级别

 参考 : https://blog.csdn.net/feixiangtianshi/article/details/49152691

[postgres@s101 /usr/pgsql-13/bin]$/usr/pgsql-13/bin/pg_basebackup   -D /var/lib/pgsql/13/backups  -Ft  -Pv  -Xf  -z  -Z5  -h 192.168.17.101 -U postgres  -p 5432
pg_basebackup: initiating base backup, waiting for checkpoint to complete
pg_basebackup: checkpoint completed
pg_basebackup: write-ahead log start point: 0/D0000028 on timeline 1
935818/935818 kB (100%), 2/2 tablespaces
pg_basebackup: write-ahead log end point: 0/D0000138
pg_basebackup: syncing data to disk ...
pg_basebackup: renaming backup_manifest.tmp to backup_manifest
pg_basebackup: base backup completed

 

查看备份文件

 

帮助文档

[root@s101 /usr/pgsql-13]#pg_basebackup --help
pg_basebackup takes a base backup of a running PostgreSQL server.

Usage:
  pg_basebackup [OPTION]...

Options controlling the output:
  -D, --pgdata=DIRECTORY receive base backup into directory
  -F, --format=p|t       output format (plain (default), tar)
  -r, --max-rate=RATE    maximum transfer rate to transfer data directory
                         (in kB/s, or use suffix "k" or "M")
  -R, --write-recovery-conf
                         write configuration for replication
  -T, --tablespace-mapping=OLDDIR=NEWDIR
                         relocate tablespace in OLDDIR to NEWDIR
      --waldir=WALDIR    location for the write-ahead log directory
  -X, --wal-method=none|fetch|stream
                         include required WAL files with specified method
  -z, --gzip             compress tar output
  -Z, --compress=0-9     compress tar output with given compression level

General options:
  -c, --checkpoint=fast|spread
                         set fast or spread checkpointing
  -C, --create-slot      create replication slot
  -l, --label=LABEL      set backup label
  -n, --no-clean         do not clean up after errors
  -N, --no-sync          do not wait for changes to be written safely to disk
  -P, --progress         show progress information
  -S, --slot=SLOTNAME    replication slot to use
  -v, --verbose          output verbose messages
  -V, --version          output version information, then exit
      --manifest-checksums=SHA{224,256,384,512}|CRC32C|NONE
                         use algorithm for manifest checksums
      --manifest-force-encode
                         hex encode all file names in manifest
      --no-estimate-size do not estimate backup size in server side
      --no-manifest      suppress generation of backup manifest
      --no-slot          prevent creation of temporary replication slot
      --no-verify-checksums
                         do not verify checksums
  -?, --help             show this help, then exit

Connection options:
  -d, --dbname=CONNSTR   connection string
  -h, --host=HOSTNAME    database server host or socket directory
  -p, --port=PORT        database server port number
  -s, --status-interval=INTERVAL
                         time between status packets sent to server (in seconds)
  -U, --username=NAME    connect as specified database user
  -w, --no-password      never prompt for password
  -W, --password         force password prompt (should happen automatically)

Report bugs to <pgsql-bugs@lists.postgresql.org>.
PostgreSQL home page: <https://www.postgresql.org/>

 

标签:pgsql,13,--,备份,PGSQL,pg,040,backup,basebackup
来源: https://www.cnblogs.com/star521/p/15072014.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有