lightdb物理備份工具之lt_probackup介紹及時間點恢復 lightdb lt_probackup 歸檔模式和流模式的區別 postgresql物理備份工具及lightdb支持情況

postgresql自帶pg_basebackup,也可用於在主庫或備庫對postgresql數據庫進行在線實時全量備份,和oracle rman全量備份還是挺類似的。如下:

[zjh@hs-10-20-30-193 zjh]$ lt_basebackup --help
lt_basebackup takes a base backup of a running LightDB server.

  lt_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
  -y, --decrypt          receive the data decrypted
  -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
                         use algorithm for manifest checksums
                         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
                         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 <>.
LightDB home page: <>

[zjh@hs-10-20-30-193 zjh]$ lt_basebackup -h -p 18383 -D test_initdb_backup -P   # 不壓縮
30831/30831 kB (100%), 1/1 tablespace

[zjh@hs-10-20-30-193 zjh]$ lt_basebackup -F t -z -h -p 18383 -D test_initdb_backup -P    # 壓縮
30846/30846 kB (100%), 1/1 tablespace

[zjh@hs-10-20-30-193 zjh]$ lt_basebackup -h -p 18383 -D test_initdb_backup -Pv
lt_basebackup: initiating base backup, waiting for checkpoint to complete
lt_basebackup: checkpoint completed
lt_basebackup: write-ahead log start point: 1/60000028 on timeline 1
lt_basebackup: starting background WAL receiver
lt_basebackup: created temporary replication slot "pg_basebackup_78391"
30926/30926 kB (100%), 1/1 tablespace
lt_basebackup: write-ahead log end point: 1/60000100
lt_basebackup: waiting for background process to finish streaming ...
lt_basebackup: syncing data to disk ...
lt_basebackup: renaming backup_manifest.tmp to backup_manifest
lt_basebackup: base backup completed


[zjh@hs-10-20-30-193 zjh]$ vim test_initdb1/lightdb.conf

recovery_target = 'immediate'
restore_command = 'cp /data1/zjh/archive/%f %p'

[zjh@hs-10-20-30-193 zjh]$ touch test_initdb1/recovery.signal

[zjh@hs-10-20-30-193 zjh]$ lt_ctl -D test_initdb1 start

[zjh@hs-10-20-30-193 zjh]$ ltsql -p18383
ltsql (13.8-23.2)
Type "help" for help.

zjh@postgres=# create table t(id int);
ERROR: cannot execute CREATE TABLE in a read-only transaction
zjh@postgres=# select pg_backend_pid();
(1 row)

zjh@postgres=# select pg_wal_replay_resume();

(1 row)

zjh@postgres=# create table t(id int);

## 一般來說,如果不做時間點恢復,不需要創建recovery.signal,直接lt_ctl start即可。


[zjh@hs-10-20-30-193 zjh]$ lt_probackup init -B /data1/zjh/lt_probackup_dir
INFO: Backup catalog '/data1/zjh/lt_probackup_dir' successfully inited
[zjh@hs-10-20-30-193 zjh]$ lt_probackup add-instance -B /data1/zjh/lt_probackup_dir -D /data1/zjh/test_initdb1 --instance test_initdb1_193_base
INFO: Instance 'test_initdb1_193_base' successfully inited
[zjh@hs-10-20-30-193 zjh]$ lt_probackup backup -B /data1/zjh/lt_probackup_dir --instance test_initdb1_193_base -b FULL -h -p 18383
INFO: Backup start, lt_probackup version: 2.4.15, instance: test_initdb1_193_base, backup ID: RVERU0, backup mode: FULL, wal mode: ARCHIVE, remote: false, compress-algorithm: none, compress-level: 1
WARNING: Current LightDB role is superuser. It is not recommended to run backup or checkdb as superuser.
INFO: wait for pg_start_backup()
INFO: Wait for WAL segment /data1/zjh/lt_probackup_dir/wal/test_initdb1_193_base/000000020000000100000004 to be archived
WARNING: By default lt_probackup assume WAL delivery method to be ARCHIVE. If continuous archiving is not set up, use '--stream' option to make autonomous backup. Otherwise check that continuous archiving works correctly.


由於lt_probackup使用較爲複雜, 推薦使用lightdb-em進行集中式備份和恢復。

lightdb lt_probackup 歸檔模式和流模式的區別


還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.