简介
类似oracle 的 rman, 用于 postgres的备份与恢复
下载
https://github.com/ossc-db/pg_rman/tree/v1.3.9
安装
tar zxvf pg_rman*.tar.gz chown postgres.postgres -r pg_rman* su - postgres cd xxx/pg_rman* make && make install
使用
开启归档
[postgres@node_206 /postgresql/pgsql/archive_log]$tail -3 /postgresql/pgsql/data/postgresql.conf #for pg_rman archive_mode = on # enables archiving; off, on, or always archive_command = 'test ! -f /postgresql/pgsql/archive_log/%f && cp %p /postgresql/pgsql/archive_log/%f'
重启 pg
pg_ctl restart -m fast
初始化
pg_rman init -b /postgresql/pgsql/pg_rman_backups
全量备份
pg_rman backup --backup-mode=full -b /postgresql/pgsql/pg_rman_backups
实例
[postgres@node_206 /postgresql/pgsql]$pg_rman init -b /postgresql/pgsql/pg_rman_backups/ info: arclog_path is set to '/postgresql/pgsql/archive_log' info: srvlog_path is set to '/postgresql/pgsql/pg_log' [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$vim ~/.bash_profile [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$source !$ source ~/.bash_profile [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$psql psql (12.3) type "help" for help. postgres=# \l list of databases name | owner | encoding | collate | ctype | access privileges -----------+----------+----------+-------------+-------------+----------------------- postgres | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | repmgr | repmgr | utf8 | en_us.utf-8 | en_us.utf-8 | template0 | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | =c/postgres + | | | | | postgres=ctc/postgres template1 | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | =c/postgres + | | | | | postgres=ctc/postgres test | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | (5 rows) postgres=# \c test you are now connected to database "test" as user "postgres". test=# select * from test; id | crt_time ----+---------------------------- 1 | 2020-11-17 23:23:31.407616 2 | 2020-11-17 23:23:31.407728 3 | 2020-11-17 23:23:31.407731 4 | 2020-11-17 23:23:31.407732 5 | 2020-11-17 23:23:31.407732 6 | 2020-11-17 23:23:31.407733 7 | 2020-11-17 23:23:31.407733 8 | 2020-11-17 23:23:31.407734 9 | 2020-11-17 23:23:31.407734 10 | 2020-11-17 23:23:31.407735 (10 rows) test=# insert into test (id) select n from generate_series(11,20) n; insert 0 10 test=# \q [postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -b /postgresql/pgsql/pg_rman_backups info: copying database files info: copying archived wal files info: backup complete info: please execute 'pg_rman validate' to verify the files are correctly copied. [postgres@node_206 /postgresql/pgsql]$pg_rman validate -b /postgresql/pgsql/pg_rman_backups info: validate: "2020-11-17 23:30:25" backup and archive log files by crc info: backup "2020-11-17 23:30:25" is valid [postgres@node_206 /postgresql/pgsql]$pg_rman show error: required parameter not specified: backup_path (-b, --backup-path) [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-11-17 23:30:25 2020-11-17 23:30:27 full 64mb 6 ok [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$psql psql (12.3) type "help" for help. postgres=# \c test you are now connected to database "test" as user "postgres". test=# insert into test (id) select n from generate_series(21,30) n; insert 0 10 test=# \q [postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=incremental -b /postgresql/pgsql/pg_rman_backups info: copying database files info: copying archived wal files info: backup complete info: please execute 'pg_rman validate' to verify the files are correctly copied. [postgres@node_206 /postgresql/pgsql]$pg_rman validate -b /postgresql/pgsql/pg_rman_backups info: validate: "2020-11-17 23:31:08" backup and archive log files by crc info: backup "2020-11-17 23:31:08" is valid [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-11-17 23:31:08 2020-11-17 23:31:10 incr 33mb 6 ok 2020-11-17 23:30:25 2020-11-17 23:30:27 full 64mb 6 ok [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$psql psql (12.3) type "help" for help. postgres=# \c test you are now connected to database "test" as user "postgres". test=# drop table test; drop table test=# \q [postgres@node_206 /postgresql/pgsql]$pg_ctl stop -m fast waiting for server to shut down.... done server stopped [postgres@node_206 /postgresql/pgsql]$pg_ctl start waiting for server to start....2020-11-17 10:32:09.637 est [58824] log: 00000: starting postgresql 12.3 on x86_64-pc-linux-gnu, compiled by gcc (gcc) 4.8.5 20150623 (red hat 4.8.5-44), 64-bit 2020-11-17 10:32:09.637 est [58824] location: postmastermain, postmaster.c:998 2020-11-17 10:32:09.637 est [58824] log: 00000: listening on ipv4 address "0.0.0.0", port 5432 2020-11-17 10:32:09.637 est [58824] location: streamserverport, pqcomm.c:593 2020-11-17 10:32:09.637 est [58824] log: 00000: listening on ipv6 address "::", port 5432 2020-11-17 10:32:09.637 est [58824] location: streamserverport, pqcomm.c:593 2020-11-17 10:32:09.643 est [58824] log: 00000: listening on unix socket "/tmp/.s.pgsql.5432" 2020-11-17 10:32:09.643 est [58824] location: streamserverport, pqcomm.c:587 2020-11-17 10:32:09.688 est [58824] log: 00000: redirecting log output to logging collector process 2020-11-17 10:32:09.688 est [58824] hint: future log output will appear in directory "/postgresql/pgsql/pg_log". 2020-11-17 10:32:09.688 est [58824] location: syslogger_start, syslogger.c:675 done server started [postgres@node_206 /postgresql/pgsql]$psql -d test psql (12.3) type "help" for help. test=# insert into test (id ) select n from generate_series(21,30) n; error: relation "test" does not exist line 1: insert into test (id ) select n from generate_series(21,30) ... ^ test=# insert into test (id ) select n from generate_series(21,30) n; error: relation "test" does not exist line 1: insert into test (id ) select n from generate_series(21,30) ... ^ test=# \d test did not find any relation named "test". test=# \q [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$repmgr cluster show id | name | role | status | upstream | location | priority | timeline | connection string ----+----------+---------+---------------+------------+----------+----------+----------+------------------------------------------------------------- 1 | node_206 | primary | * running | | default | 100 | 6 | host=node_206 user=repmgr dbname=repmgr connect_timeout=2 2 | node_205 | standby | ? unreachable | ? node_206 | default | 100 | | host=node_205 user=repmgr dbname=repmgr connect_timeout=2 warning: following issues were detected - unable to connect to node "node_205" (id: 2) - node "node_205" (id: 2) is registered as an active standby but is unreachable hint: execute with --verbose option to see connection error messages [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-11-17 23:31:08 2020-11-17 23:31:10 incr 33mb 6 ok 2020-11-17 23:30:25 2020-11-17 23:30:27 full 64mb 6 ok [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ --restore-target-time='2020-11-17 23:30:25' pg_rman: unrecognized option '--restore-target-time=2020-11-17 23:30:25' error: option is not specified hint: try "pg_rman --help" for more information. [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-11-17 23:30:25' error: postgresql server is running hint: please stop postgresql server before executing restore. [postgres@node_206 /postgresql/pgsql]$pg_ctl stop -m fast waiting for server to shut down.... done server stopped [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-11-17 23:30:25' error: cannot do restore detail: there is no valid full backup which can be used for given recovery condition. [postgres@node_206 /postgresql/pgsql]$pg_rman validate -b /postgresql/pgsql/pg_rman_backups [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-11-17 23:30:25' error: cannot do restore detail: there is no valid full backup which can be used for given recovery condition. [postgres@node_206 /postgresql/pgsql]$pg_ctl start waiting for server to start....2020-11-17 10:34:02.558 est [58862] log: 00000: starting postgresql 12.3 on x86_64-pc-linux-gnu, compiled by gcc (gcc) 4.8.5 20150623 (red hat 4.8.5-44), 64-bit 2020-11-17 10:34:02.558 est [58862] location: postmastermain, postmaster.c:998 2020-11-17 10:34:02.559 est [58862] log: 00000: listening on ipv4 address "0.0.0.0", port 5432 2020-11-17 10:34:02.559 est [58862] location: streamserverport, pqcomm.c:593 2020-11-17 10:34:02.559 est [58862] log: 00000: listening on ipv6 address "::", port 5432 2020-11-17 10:34:02.559 est [58862] location: streamserverport, pqcomm.c:593 2020-11-17 10:34:02.565 est [58862] log: 00000: listening on unix socket "/tmp/.s.pgsql.5432" 2020-11-17 10:34:02.565 est [58862] location: streamserverport, pqcomm.c:587 2020-11-17 10:34:02.608 est [58862] log: 00000: redirecting log output to logging collector process 2020-11-17 10:34:02.608 est [58862] hint: future log output will appear in directory "/postgresql/pgsql/pg_log". 2020-11-17 10:34:02.608 est [58862] location: syslogger_start, syslogger.c:675 done server started [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-11-17 23:31:08 2020-11-17 23:31:10 incr 33mb 6 ok 2020-11-17 23:30:25 2020-11-17 23:30:27 full 64mb 6 ok [postgres@node_206 /postgresql/pgsql]$pg_rman validate -b /postgresql/pgsql/pg_rman_backups [postgres@node_206 /postgresql/pgsql]$pg_ctl stop waiting for server to shut down.... done server stopped [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-11-17 23:30:25' error: cannot do restore detail: there is no valid full backup which can be used for given recovery condition. [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_ctl start waiting for server to start....2020-11-17 10:34:22.842 est [58881] log: 00000: starting postgresql 12.3 on x86_64-pc-linux-gnu, compiled by gcc (gcc) 4.8.5 20150623 (red hat 4.8.5-44), 64-bit 2020-11-17 10:34:22.842 est [58881] location: postmastermain, postmaster.c:998 2020-11-17 10:34:22.842 est [58881] log: 00000: listening on ipv4 address "0.0.0.0", port 5432 2020-11-17 10:34:22.842 est [58881] location: streamserverport, pqcomm.c:593 2020-11-17 10:34:22.842 est [58881] log: 00000: listening on ipv6 address "::", port 5432 2020-11-17 10:34:22.842 est [58881] location: streamserverport, pqcomm.c:593 2020-11-17 10:34:22.846 est [58881] log: 00000: listening on unix socket "/tmp/.s.pgsql.5432" 2020-11-17 10:34:22.846 est [58881] location: streamserverport, pqcomm.c:587 2020-11-17 10:34:22.888 est [58881] log: 00000: redirecting log output to logging collector process 2020-11-17 10:34:22.888 est [58881] hint: future log output will appear in directory "/postgresql/pgsql/pg_log". 2020-11-17 10:34:22.888 est [58881] location: syslogger_start, syslogger.c:675 done server started [postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -b /postgresql/pgsql/pg_rman_backups info: copying database files info: copying archived wal files info: backup complete info: please execute 'pg_rman validate' to verify the files are correctly copied. [postgres@node_206 /postgresql/pgsql]$pg_rman validate -b /postgresql/pgsql/pg_rman_backups info: validate: "2020-11-17 23:34:26" backup and archive log files by crc info: backup "2020-11-17 23:34:26" is valid [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-11-17 23:34:26 2020-11-17 23:34:28 full 114mb 6 ok 2020-11-17 23:31:08 2020-11-17 23:31:10 incr 33mb 6 ok 2020-11-17 23:30:25 2020-11-17 23:30:27 full 64mb 6 ok [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$psql psql (12.3) type "help" for help. postgres=# \l list of databases name | owner | encoding | collate | ctype | access privileges -----------+----------+----------+-------------+-------------+----------------------- postgres | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | repmgr | repmgr | utf8 | en_us.utf-8 | en_us.utf-8 | template0 | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | =c/postgres + | | | | | postgres=ctc/postgres template1 | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | =c/postgres + | | | | | postgres=ctc/postgres test | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | (5 rows) postgres=# \c test you are now connected to database "test" as user "postgres". test=# \dt did not find any relations. test=# create table test(id int); create table test=# drop table test(id int); error: syntax error at or near "(" line 1: drop table test(id int); ^ test=# test=# \q [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$vim $pgdata/postgresql.conf postgres=# \l list of databases name | owner | encoding | collate | ctype | access privileges -----------+----------+----------+-------------+-------------+----------------------- postgres | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | repmgr | repmgr | utf8 | en_us.utf-8 | en_us.utf-8 | template0 | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | =c/postgres + | | | | | postgres=ctc/postgres template1 | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | =c/postgres + | | | | | postgres=ctc/postgres test | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | (5 rows) postgres=# \c test you are now connected to database "test" as user "postgres". test=# \dt did not find any relations. test=# create table test(id int); create table test=# drop table test(id int); error: syntax error at or near "(" line 1: drop table test(id int); ^ test=# test=# \q [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$vim $pgdata/postgresql.conf [postgres@node_206 /postgresql/pgsql]$vim $pgdata/postgresql.conf list of databases name | owner | encoding | collate | ctype | access privileges -----------+----------+----------+-------------+-------------+----------------------- postgres | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | repmgr | repmgr | utf8 | en_us.utf-8 | en_us.utf-8 | template0 | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | =c/postgres + | | | | | postgres=ctc/postgres template1 | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | =c/postgres + | | | | | postgres=ctc/postgres test | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | (5 rows) postgres=# \c test you are now connected to database "test" as user "postgres". test=# \dt did not find any relations. test=# create table test(id int); create table test=# drop table test(id int); error: syntax error at or near "(" line 1: drop table test(id int); ^ test=# test=# \q [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$vim $pgdata/postgresql.conf [postgres@node_206 /postgresql/pgsql]$vim $pgdata/postgresql.conf [postgres@node_206 /postgresql/pgsql]$pg_ctl restart -m fast waiting for server to shut down.... done server stopped waiting for server to start....2020-11-17 10:36:41.191 est [58933] log: 00000: starting postgresql 12.3 on x86_64-pc-linux-gnu, compiled by gcc (gcc) 4.8.5 20150623 (red hat 4.8.5-44), 64-bit 2020-11-17 10:36:41.191 est [58933] location: postmastermain, postmaster.c:998 2020-11-17 10:36:41.192 est [58933] log: 00000: listening on ipv4 address "0.0.0.0", port 5432 2020-11-17 10:36:41.192 est [58933] location: streamserverport, pqcomm.c:593 2020-11-17 10:36:41.192 est [58933] log: 00000: listening on ipv6 address "::", port 5432 2020-11-17 10:36:41.192 est [58933] location: streamserverport, pqcomm.c:593 2020-11-17 10:36:41.197 est [58933] log: 00000: listening on unix socket "/tmp/.s.pgsql.5432" 2020-11-17 10:36:41.197 est [58933] location: streamserverport, pqcomm.c:587 2020-11-17 10:36:41.229 est [58933] log: 00000: redirecting log output to logging collector process 2020-11-17 10:36:41.229 est [58933] hint: future log output will appear in directory "/postgresql/pgsql/pg_log". 2020-11-17 10:36:41.229 est [58933] location: syslogger_start, syslogger.c:675 done server started [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ll total 28 drwxr-xr-x. 2 postgres postgres 4096 nov 17 23:36 archive_log drwxrwxr-x. 2 postgres postgres 6 nov 17 15:51 backups drwxr-xr-x. 2 postgres postgres 4096 nov 17 16:43 bin drwx------. 19 postgres postgres 4096 nov 17 23:36 data drwxr-xr-x. 6 postgres postgres 4096 nov 15 16:14 include drwxr-xr-x. 4 postgres postgres 4096 nov 17 06:37 lib drwxr-xr-x. 2 postgres postgres 4096 nov 17 23:36 pg_log drwxrwxr-x. 5 postgres postgres 104 nov 17 23:30 pg_rman_backups drwxr-xr-x. 8 postgres postgres 4096 nov 15 16:14 share [postgres@node_206 /postgresql/pgsql]$rm -rf archive_log/* [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$rm -rf pg_rman_backups/* [postgres@node_206 /postgresql/pgsql]$ll total 24 drwxr-xr-x. 2 postgres postgres 6 nov 17 23:36 archive_log drwxrwxr-x. 2 postgres postgres 6 nov 17 15:51 backups drwxr-xr-x. 2 postgres postgres 4096 nov 17 16:43 bin drwx------. 19 postgres postgres 4096 nov 17 23:36 data drwxr-xr-x. 6 postgres postgres 4096 nov 15 16:14 include drwxr-xr-x. 4 postgres postgres 4096 nov 17 06:37 lib drwxr-xr-x. 2 postgres postgres 4096 nov 17 23:36 pg_log drwxrwxr-x. 2 postgres postgres 6 nov 17 23:36 pg_rman_backups drwxr-xr-x. 8 postgres postgres 4096 nov 15 16:14 share [postgres@node_206 /postgresql/pgsql]$pwd /postgresql/pgsql [postgres@node_206 /postgresql/pgsql]$ls archive_log backups bin data include lib pg_log pg_rman_backups share [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ll total 24 drwxr-xr-x. 2 postgres postgres 6 nov 17 23:36 archive_log drwxrwxr-x. 2 postgres postgres 6 nov 17 15:51 backups drwxr-xr-x. 2 postgres postgres 4096 nov 17 16:43 bin drwx------. 19 postgres postgres 4096 nov 17 23:36 data drwxr-xr-x. 6 postgres postgres 4096 nov 15 16:14 include drwxr-xr-x. 4 postgres postgres 4096 nov 17 06:37 lib drwxr-xr-x. 2 postgres postgres 4096 nov 17 23:36 pg_log drwxrwxr-x. 2 postgres postgres 6 nov 17 23:36 pg_rman_backups drwxr-xr-x. 8 postgres postgres 4096 nov 15 16:14 share [postgres@node_206 /postgresql/pgsql]$pwd /postgresql/pgsql [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$vim $pgdata/postgresql.conf total 24 drwxr-xr-x. 2 postgres postgres 6 nov 17 23:36 archive_log drwxrwxr-x. 2 postgres postgres 6 nov 17 15:51 backups drwxr-xr-x. 2 postgres postgres 4096 nov 17 16:43 bin drwx------. 19 postgres postgres 4096 nov 17 23:36 data drwxr-xr-x. 6 postgres postgres 4096 nov 15 16:14 include drwxr-xr-x. 4 postgres postgres 4096 nov 17 06:37 lib drwxr-xr-x. 2 postgres postgres 4096 nov 17 23:36 pg_log drwxrwxr-x. 2 postgres postgres 6 nov 17 23:36 pg_rman_backups drwxr-xr-x. 8 postgres postgres 4096 nov 15 16:14 share [postgres@node_206 /postgresql/pgsql]$pwd /postgresql/pgsql [postgres@node_206 /postgresql/pgsql]$ls archive_log backups bin data include lib pg_log pg_rman_backups share [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ll total 24 drwxr-xr-x. 2 postgres postgres 6 nov 17 23:36 archive_log drwxrwxr-x. 2 postgres postgres 6 nov 17 15:51 backups drwxr-xr-x. 2 postgres postgres 4096 nov 17 16:43 bin drwx------. 19 postgres postgres 4096 nov 17 23:36 data drwxr-xr-x. 6 postgres postgres 4096 nov 15 16:14 include drwxr-xr-x. 4 postgres postgres 4096 nov 17 06:37 lib drwxr-xr-x. 2 postgres postgres 4096 nov 17 23:36 pg_log drwxrwxr-x. 2 postgres postgres 6 nov 17 23:36 pg_rman_backups drwxr-xr-x. 8 postgres postgres 4096 nov 15 16:14 share [postgres@node_206 /postgresql/pgsql]$pwd /postgresql/pgsql [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$vim $pgdata/postgresql.conf [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$tail -3 $pgdata/postgresql.conf #for pg_rman archive_mode = on # enables archiving; off, on, or always archive_command = 'test ! -f /postgresql/pgsql/archive_log/%f && cp %p /postgresql/pgsql/archive_log/%f' [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_ctl restart -m fast waiting for server to shut down.... done server stopped waiting for server to start....2020-11-17 10:45:13.636 est [59035] log: 00000: starting postgresql 12.3 on x86_64-pc-linux-gnu, compiled by gcc (gcc) 4.8.5 20150623 (red hat 4.8.5-44), 64-bit 2020-11-17 10:45:13.636 est [59035] location: postmastermain, postmaster.c:998 2020-11-17 10:45:13.638 est [59035] log: 00000: listening on ipv4 address "0.0.0.0", port 5432 2020-11-17 10:45:13.638 est [59035] location: streamserverport, pqcomm.c:593 2020-11-17 10:45:13.638 est [59035] log: 00000: listening on ipv6 address "::", port 5432 2020-11-17 10:45:13.638 est [59035] location: streamserverport, pqcomm.c:593 2020-11-17 10:45:13.644 est [59035] log: 00000: listening on unix socket "/tmp/.s.pgsql.5432" 2020-11-17 10:45:13.644 est [59035] location: streamserverport, pqcomm.c:587 2020-11-17 10:45:13.696 est [59035] log: 00000: redirecting log output to logging collector process 2020-11-17 10:45:13.696 est [59035] hint: future log output will appear in directory "/postgresql/pgsql/pg_log". 2020-11-17 10:45:13.696 est [59035] location: syslogger_start, syslogger.c:675 done server started [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ll total 24 drwxr-xr-x. 2 postgres postgres 6 nov 17 23:36 archive_log drwxrwxr-x. 2 postgres postgres 6 nov 17 15:51 backups drwxr-xr-x. 2 postgres postgres 4096 nov 17 16:43 bin drwx------. 19 postgres postgres 4096 nov 17 23:45 data drwxr-xr-x. 6 postgres postgres 4096 nov 15 16:14 include drwxr-xr-x. 4 postgres postgres 4096 nov 17 06:37 lib drwxr-xr-x. 2 postgres postgres 4096 nov 17 23:45 pg_log drwxrwxr-x. 2 postgres postgres 6 nov 17 23:36 pg_rman_backups drwxr-xr-x. 8 postgres postgres 4096 nov 15 16:14 share [postgres@node_206 /postgresql/pgsql]$pg_rman init -b /postgresql/pgsql/pg_rman_backups/ info: arclog_path is set to '/postgresql/pgsql/archive_log' info: srvlog_path is set to '/postgresql/pgsql/pg_log' [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$psql psql (12.3) type "help" for help. postgres=# \l list of databases name | owner | encoding | collate | ctype | access privileges -----------+----------+----------+-------------+-------------+----------------------- postgres | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | repmgr | repmgr | utf8 | en_us.utf-8 | en_us.utf-8 | template0 | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | =c/postgres + | | | | | postgres=ctc/postgres template1 | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | =c/postgres + | | | | | postgres=ctc/postgres test | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | (5 rows) postgres=# \c test you are now connected to database "test" as user "postgres". test=# \dt list of relations schema | name | type | owner --------+------+-------+---------- public | test | table | postgres (1 row) test=# drop table test test-# ; drop table test=# create table test(id int, crt_time timestamp); create table test=# insert into test(id) select n from generate_series(1,100) n; insert 0 100 test=# \q [postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -b /postgresql/pgsql/pg_rman_backups info: copying database files info: copying archived wal files info: backup complete info: please execute 'pg_rman validate' to verify the files are correctly copied. [postgres@node_206 /postgresql/pgsql]$pg_rman validate -b /postgresql/pgsql/pg_rman_backups info: validate: "2020-11-17 23:46:22" backup and archive log files by crc info: backup "2020-11-17 23:46:22" is valid [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$psql psql (12.3) type "help" for help. postgres=# \c test you are now connected to database "test" as user "postgres". test=# select * from test; id | crt_time -----+---------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | (100 rows) test=# test=# test=# test=# test=# test=# test=# test=# test=# test=# insert into test (id) select n from generate_series(101,110) n; insert 0 10 test=# \q [postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=incremental -b /postgresql/pgsql/pg_rman_backups info: copying database files info: copying archived wal files info: backup complete info: please execute 'pg_rman validate' to verify the files are correctly copied. [postgres@node_206 /postgresql/pgsql]$pg_rman validate -b /postgresql/pgsql/pg_rman_backups info: validate: "2020-11-17 23:47:09" backup and archive log files by crc info: backup "2020-11-17 23:47:09" is valid [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-11-17 23:47:09 2020-11-17 23:47:12 incr 33mb 6 ok 2020-11-17 23:46:22 2020-11-17 23:46:24 full 64mb 6 ok [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$psql -d test psql (12.3) type "help" for help. test=# create table test2( like test ); create table test=# insert into test2(id) select n from generate_serires(1,100) n; error: function generate_serires(integer, integer) does not exist line 1: insert into test2(id) select n from generate_serires(1,100) ... ^ hint: no function matches the given name and argument types. you might need to add explicit type casts. test=# test=# insert into test2(id) select n from generate_series(1,100) n; insert 0 100 test=# \q [postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -b /postgresql/pgsql/pg_rman_backups info: copying database files info: copying archived wal files info: backup complete info: please execute 'pg_rman validate' to verify the files are correctly copied. [postgres@node_206 /postgresql/pgsql]$pg_rman validate -b /postgresql/pgsql/pg_rman_backups info: validate: "2020-11-17 23:49:32" backup and archive log files by crc info: backup "2020-11-17 23:49:32" is valid [postgres@node_206 /postgresql/pgsql]$psql -d test psql (12.3) type "help" for help. test=# insert into test(id) select n from generate_series(101,100) n; insert 0 0 test=# \q [postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=incremental -b /postgresql/pgsql/pg_rman_backups info: copying database files info: copying archived wal files info: backup complete info: please execute 'pg_rman validate' to verify the files are correctly copied. [postgres@node_206 /postgresql/pgsql]$pg_rman validate -b /postgresql/pgsql/pg_rman_backups info: validate: "2020-11-17 23:49:59" backup and archive log files by crc info: backup "2020-11-17 23:49:59" is valid [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-11-17 23:49:59 2020-11-17 23:50:01 incr 33mb 6 ok 2020-11-17 23:49:32 2020-11-17 23:49:35 full 64mb 6 ok 2020-11-17 23:47:09 2020-11-17 23:47:12 incr 33mb 6 ok 2020-11-17 23:46:22 2020-11-17 23:46:24 full 64mb 6 ok [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman delete 2020-11-17 23:47:09 -b /postgresql/pgsql/pg_rman_backups/ warning: cannot delete backup with start time "2020-11-17 23:47:09" detail: this is the incremental backup necessary for successful recovery. warning: cannot delete backup with start time "2020-11-17 23:46:22" detail: this is the latest full backup necessary for successful recovery. [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-11-17 23:49:59 2020-11-17 23:50:01 incr 33mb 6 ok 2020-11-17 23:49:32 2020-11-17 23:49:35 full 64mb 6 ok 2020-11-17 23:47:09 2020-11-17 23:47:12 incr 33mb 6 ok 2020-11-17 23:46:22 2020-11-17 23:46:24 full 64mb 6 ok [postgres@node_206 /postgresql/pgsql]$pg_rman delete -f 2020-11-17 23:47:09 -b /postgresql/pgsql/pg_rman_backups/ warning: using force option will make some of the remaining backups unusable detail: any remaining incremental backups that are older than the oldest available full backup cannot be restored. info: delete the backup with start time: "2020-11-17 23:47:09" info: delete the backup with start time: "2020-11-17 23:46:22" [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ll pg_rman_backups/ total 8 drwx------. 6 postgres postgres 62 nov 17 23:49 20201117 drwx------. 4 postgres postgres 34 nov 17 23:45 backup -rw-rw-r--. 1 postgres postgres 84 nov 17 23:45 pg_rman.ini -rw-rw-r--. 1 postgres postgres 40 nov 17 23:45 system_identifier drwx------. 2 postgres postgres 6 nov 17 23:45 timeline_history [postgres@node_206 /postgresql/pgsql]$ll pg_rman_backups/20201117/ total 0 drwx------. 2 postgres postgres 89 nov 17 23:50 234622 drwx------. 2 postgres postgres 89 nov 17 23:50 234709 drwx------. 5 postgres postgres 133 nov 17 23:49 234932 drwx------. 5 postgres postgres 133 nov 17 23:50 234959 [postgres@node_206 /postgresql/pgsql]$ll pg_rman_backups/20201117/234622/ total 112 -rw-rw-r--. 1 postgres postgres 433 nov 17 23:50 backup.ini -rw-rw-r--. 1 postgres postgres 226 nov 17 23:46 file_arclog.txt -rw-rw-r--. 1 postgres postgres 99521 nov 17 23:46 file_database.txt -rwx------. 1 postgres postgres 764 nov 17 23:46 mkdirs.sh [postgres@node_206 /postgresql/pgsql]$ll pg_rman_backups/20201117/2347 ls: cannot access pg_rman_backups/20201117/2347: no such file or directory [postgres@node_206 /postgresql/pgsql]$ll pg_rman_backups/20201117/234709/ total 124 -rw-rw-r--. 1 postgres postgres 438 nov 17 23:50 backup.ini -rw-rw-r--. 1 postgres postgres 468 nov 17 23:47 file_arclog.txt -rw-rw-r--. 1 postgres postgres 113305 nov 17 23:47 file_database.txt -rwx------. 1 postgres postgres 764 nov 17 23:47 mkdirs.sh [postgres@node_206 /postgresql/pgsql]$ll pg_rman_backups/20201117/234932/ total 116 drwx------. 2 postgres postgres 118 nov 17 23:49 arclog -rw-rw-r--. 1 postgres postgres 428 nov 17 23:49 backup.ini drwx------. 19 postgres postgres 4096 nov 17 23:49 database -rw-rw-r--. 1 postgres postgres 708 nov 17 23:49 file_arclog.txt -rw-rw-r--. 1 postgres postgres 99583 nov 17 23:49 file_database.txt -rwx------. 1 postgres postgres 764 nov 17 23:49 mkdirs.sh drwx------. 2 postgres postgres 6 nov 17 23:49 srvlog [postgres@node_206 /postgresql/pgsql]$pg_rman purge error: required parameter not specified: backup_path (-b, --backup-path) [postgres@node_206 /postgresql/pgsql]$pg_rman purge -b /postgresql/pgsql/pg_rman_backups/ info: deleted backup "2020-11-17 23:47:09" is purged info: deleted backup "2020-11-17 23:46:22" is purged [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ll pg_rman_backups/20201117/234622/ ls: cannot access pg_rman_backups/20201117/234622/: no such file or directory [postgres@node_206 /postgresql/pgsql]$ll pg_rman_backups/20201117 total 0 drwx------. 5 postgres postgres 133 nov 17 23:49 234932 drwx------. 5 postgres postgres 133 nov 17 23:50 234959 [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-11-17 23:49:59 2020-11-17 23:50:01 incr 33mb 6 ok 2020-11-17 23:49:32 2020-11-17 23:49:35 full 64mb 6 ok [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$psql psql (12.3) type "help" for help. postgres=# drop database test; drop database postgres=# \q [postgres@node_206 /postgresql/pgsql]$pg_ctl stop -m fast waiting for server to shut down.... done server stopped [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-11-17 23:49:32' error: cannot do restore detail: there is no valid full backup which can be used for given recovery condition. [postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -b /postgresql/pgsql/pg_rman_backups error: could not connect to database postgres: could not connect to server: no such file or directory is the server running locally and accepting connections on unix domain socket "/tmp/.s.pgsql.5432"? [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_ctl start waiting for server to start....2020-11-17 10:53:41.927 est [59212] log: 00000: starting postgresql 12.3 on x86_64-pc-linux-gnu, compiled by gcc (gcc) 4.8.5 20150623 (red hat 4.8.5-44), 64-bit 2020-11-17 10:53:41.927 est [59212] location: postmastermain, postmaster.c:998 2020-11-17 10:53:41.928 est [59212] log: 00000: listening on ipv4 address "0.0.0.0", port 5432 2020-11-17 10:53:41.928 est [59212] location: streamserverport, pqcomm.c:593 2020-11-17 10:53:41.928 est [59212] log: 00000: listening on ipv6 address "::", port 5432 2020-11-17 10:53:41.928 est [59212] location: streamserverport, pqcomm.c:593 2020-11-17 10:53:41.929 est [59212] log: 00000: listening on unix socket "/tmp/.s.pgsql.5432" 2020-11-17 10:53:41.929 est [59212] location: streamserverport, pqcomm.c:587 2020-11-17 10:53:41.977 est [59212] log: 00000: redirecting log output to logging collector process 2020-11-17 10:53:41.977 est [59212] hint: future log output will appear in directory "/postgresql/pgsql/pg_log". 2020-11-17 10:53:41.977 est [59212] location: syslogger_start, syslogger.c:675 done server started [postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -b /postgresql/pgsql/pg_rman_backups info: copying database files info: copying archived wal files info: backup complete info: please execute 'pg_rman validate' to verify the files are correctly copied. [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman validate -b /postgresql/pgsql/pg_rman_backups info: validate: "2020-11-17 23:53:43" backup and archive log files by crc info: backup "2020-11-17 23:53:43" is valid [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-11-17 23:53:43 2020-11-17 23:53:45 full 75mb 6 ok 2020-11-17 23:53:39 2020-11-17 23:53:39 full 0b 0 error 2020-11-17 23:49:59 2020-11-17 23:50:01 incr 33mb 6 ok 2020-11-17 23:49:32 2020-11-17 23:49:35 full 64mb 6 ok [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$psql -d test psql: error: could not connect to server: fatal: database "test" does not exist [postgres@node_206 /postgresql/pgsql]$psql psql (12.3) type "help" for help. postgres=# create database test; create database postgres=# \c test you are now connected to database "test" as user "postgres". test=# create table test2(id int, crt_time timestamp ); create table test=# insert into test2(id) select n from generate_series(1,100) n; insert 0 100 test=# test=# \q [postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -b /postgresql/pgsql/pg_rman_backups info: copying database files info: copying archived wal files info: backup complete info: please execute 'pg_rman validate' to verify the files are correctly copied. [postgres@node_206 /postgresql/pgsql]$pg_rman validate -b /postgresql/pgsql/pg_rman_backups info: validate: "2020-11-17 23:58:53" backup and archive log files by crc info: backup "2020-11-17 23:58:53" is valid [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-11-17 23:58:53 2020-11-17 23:58:55 full 64mb 6 ok 2020-11-17 23:53:43 2020-11-17 23:53:45 full 75mb 6 ok 2020-11-17 23:53:39 2020-11-17 23:53:39 full 0b 0 error 2020-11-17 23:49:59 2020-11-17 23:50:01 incr 33mb 6 ok 2020-11-17 23:49:32 2020-11-17 23:49:35 full 64mb 6 ok [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman delete -f 2020-11-17 23:53:39 -b /postgresql/pgsql/pg_rman_backups/ warning: using force option will make some of the remaining backups unusable detail: any remaining incremental backups that are older than the oldest available full backup cannot be restored. info: delete the backup with start time: "2020-11-17 23:53:39" info: delete the backup with start time: "2020-11-17 23:49:59" info: delete the backup with start time: "2020-11-17 23:49:32" [postgres@node_206 /postgresql/pgsql]$pg_rman purge -b /postgresql/pgsql/pg_rman_backups/ info: deleted backup "2020-11-17 23:53:39" is purged info: deleted backup "2020-11-17 23:49:59" is purged info: deleted backup "2020-11-17 23:49:32" is purged [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-11-17 23:58:53 2020-11-17 23:58:55 full 64mb 6 ok 2020-11-17 23:53:43 2020-11-17 23:53:45 full 75mb 6 ok [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$psql psql (12.3) type "help" for help. postgres=# \c test you are now connected to database "test" as user "postgres". test=# \dt list of relations schema | name | type | owner --------+-------+-------+---------- public | test2 | table | postgres (1 row) test=# \c postgres you are now connected to database "postgres" as user "postgres". postgres=# drop database test; drop database postgres=# \q [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-11-17 23:58:53 2020-11-17 23:58:55 full 64mb 6 ok 2020-11-17 23:53:43 2020-11-17 23:53:45 full 75mb 6 ok [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-11-17 23:58:53' error: postgresql server is running hint: please stop postgresql server before executing restore. [postgres@node_206 /postgresql/pgsql]$pg_ctl stop -m fast waiting for server to shut down.... done server stopped [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-11-17 23:58:53' info: the recovery target timeline id is not given info: use timeline id of current database cluster as recovery target: 6 info: calculating timeline branches to be used to recovery target point info: searching latest full backup which can be used as restore start point info: found the full backup can be used as base in recovery: "2020-11-17 23:53:43" info: copying online wal files and server log files info: clearing restore destination info: validate: "2020-11-17 23:53:43" backup and archive log files by size info: backup "2020-11-17 23:53:43" is valid info: restoring database files from the full mode backup "2020-11-17 23:53:43" info: searching incremental backup to be restored info: searching backup which contained archived wal files to be restored info: backup "2020-11-17 23:53:43" is valid info: restoring wal files from backup "2020-11-17 23:53:43" info: backup "2020-11-17 23:58:53" is valid info: restoring wal files from backup "2020-11-17 23:58:53" info: restoring online wal files and server log files info: add recovery related options to postgresql.conf info: generating recovery.signal info: restore complete hint: recovery will start automatically when the postgresql server is started. [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -b /postgresql/pgsql/pg_rman_backups error: could not connect to database postgres: could not connect to server: no such file or directory is the server running locally and accepting connections on unix domain socket "/tmp/.s.pgsql.5432"? [postgres@node_206 /postgresql/pgsql]$pg_ctl start waiting for server to start....2020-11-17 11:00:30.910 est [59357] log: 00000: starting postgresql 12.3 on x86_64-pc-linux-gnu, compiled by gcc (gcc) 4.8.5 20150623 (red hat 4.8.5-44), 64-bit 2020-11-17 11:00:30.910 est [59357] location: postmastermain, postmaster.c:998 2020-11-17 11:00:30.910 est [59357] log: 00000: listening on ipv4 address "0.0.0.0", port 5432 2020-11-17 11:00:30.910 est [59357] location: streamserverport, pqcomm.c:593 2020-11-17 11:00:30.910 est [59357] log: 00000: listening on ipv6 address "::", port 5432 2020-11-17 11:00:30.910 est [59357] location: streamserverport, pqcomm.c:593 2020-11-17 11:00:30.914 est [59357] log: 00000: listening on unix socket "/tmp/.s.pgsql.5432" 2020-11-17 11:00:30.914 est [59357] location: streamserverport, pqcomm.c:587 2020-11-17 11:00:30.965 est [59357] log: 00000: redirecting log output to logging collector process 2020-11-17 11:00:30.965 est [59357] hint: future log output will appear in directory "/postgresql/pgsql/pg_log". 2020-11-17 11:00:30.965 est [59357] location: syslogger_start, syslogger.c:675 done server started [postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -b /postgresql/pgsql/pg_rman_backups info: copying database files error: query failed: error: recovery is in progress hint: pg_walfile_name_offset() cannot be executed during recovery. query was: select * from pg_walfile_name_offset(pg_start_backup($1, $2, $3)) [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$rm -f data/recovery.signal [postgres@node_206 /postgresql/pgsql]$pg_ctl restart -m fast waiting for server to shut down.... done server stopped waiting for server to start....2020-11-17 11:00:51.204 est [59374] log: 00000: starting postgresql 12.3 on x86_64-pc-linux-gnu, compiled by gcc (gcc) 4.8.5 20150623 (red hat 4.8.5-44), 64-bit 2020-11-17 11:00:51.204 est [59374] location: postmastermain, postmaster.c:998 2020-11-17 11:00:51.205 est [59374] log: 00000: listening on ipv4 address "0.0.0.0", port 5432 2020-11-17 11:00:51.205 est [59374] location: streamserverport, pqcomm.c:593 2020-11-17 11:00:51.205 est [59374] log: 00000: listening on ipv6 address "::", port 5432 2020-11-17 11:00:51.205 est [59374] location: streamserverport, pqcomm.c:593 2020-11-17 11:00:51.210 est [59374] log: 00000: listening on unix socket "/tmp/.s.pgsql.5432" 2020-11-17 11:00:51.210 est [59374] location: streamserverport, pqcomm.c:587 2020-11-17 11:00:51.270 est [59374] log: 00000: redirecting log output to logging collector process 2020-11-17 11:00:51.270 est [59374] hint: future log output will appear in directory "/postgresql/pgsql/pg_log". 2020-11-17 11:00:51.270 est [59374] location: syslogger_start, syslogger.c:675 done server started [postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -b /postgresql/pgsql/pg_rman_backups info: copying database files info: copying archived wal files info: backup complete info: please execute 'pg_rman validate' to verify the files are correctly copied. [postgres@node_206 /postgresql/pgsql]$pg_rman validate -b /postgresql/pgsql/pg_rman_backups info: validate: "2020-11-18 00:00:53" backup and archive log files by crc info: backup "2020-11-18 00:00:53" is valid [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-11-18 00:00:53 2020-11-18 00:00:55 full 159mb 6 ok 2020-11-18 00:00:34 2020-11-18 00:00:34 full 0b 0 error 2020-11-18 00:00:26 2020-11-18 00:00:26 full 0b 0 error 2020-11-17 23:58:53 2020-11-17 23:58:55 full 64mb 6 ok 2020-11-17 23:53:43 2020-11-17 23:53:45 full 75mb 6 ok [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$psql psql (12.3) type "help" for help. postgres=# \l list of databases name | owner | encoding | collate | ctype | access privileges -----------+----------+----------+-------------+-------------+----------------------- postgres | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | repmgr | repmgr | utf8 | en_us.utf-8 | en_us.utf-8 | template0 | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | =c/postgres + | | | | | postgres=ctc/postgres template1 | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | =c/postgres + | | | | | postgres=ctc/postgres (4 rows) postgres=# \c test fatal: database "test" does not exist previous connection kept postgres=# \q [postgres@node_206 /postgresql/pgsql]$vim $pgdata/postgresql.conf [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-11-18 00:00:53 2020-11-18 00:00:55 full 159mb 6 ok 2020-11-18 00:00:34 2020-11-18 00:00:34 full 0b 0 error 2020-11-18 00:00:26 2020-11-18 00:00:26 full 0b 0 error 2020-11-17 23:58:53 2020-11-17 23:58:55 full 64mb 6 ok 2020-11-17 23:53:43 2020-11-17 23:53:45 full 75mb 6 ok [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$psql psql (12.3) type "help" for help. postgres=# \l list of databases name | owner | encoding | collate | ctype | access privileges -----------+----------+----------+-------------+-------------+----------------------- postgres | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | repmgr | repmgr | utf8 | en_us.utf-8 | en_us.utf-8 | template0 | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | =c/postgres + | | | | | postgres=ctc/postgres template1 | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | =c/postgres + | | | | | postgres=ctc/postgres (4 rows) postgres=# \c test fatal: database "test" does not exist previous connection kept postgres=# \q [postgres@node_206 /postgresql/pgsql]$vim $pgdata/postgresql.conf [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_ctl restart -m fast waiting for server to shut down.... done server stopped waiting for server to start....2020-11-17 11:01:30.816 est [59423] log: 00000: starting postgresql 12.3 on x86_64-pc-linux-gnu, compiled by gcc (gcc) 4.8.5 20150623 (red hat 4.8.5-44), 64-bit 2020-11-17 11:01:30.816 est [59423] location: postmastermain, postmaster.c:998 2020-11-17 11:01:30.822 est [59423] log: 00000: listening on ipv4 address "0.0.0.0", port 5432 2020-11-17 11:01:30.822 est [59423] location: streamserverport, pqcomm.c:593 2020-11-17 11:01:30.822 est [59423] log: 00000: listening on ipv6 address "::", port 5432 2020-11-17 11:01:30.822 est [59423] location: streamserverport, pqcomm.c:593 2020-11-17 11:01:30.837 est [59423] log: 00000: listening on unix socket "/tmp/.s.pgsql.5432" 2020-11-17 11:01:30.837 est [59423] location: streamserverport, pqcomm.c:587 2020-11-17 11:01:30.877 est [59423] log: 00000: redirecting log output to logging collector process 2020-11-17 11:01:30.877 est [59423] hint: future log output will appear in directory "/postgresql/pgsql/pg_log". 2020-11-17 11:01:30.877 est [59423] location: syslogger_start, syslogger.c:675 done server started [postgres@node_206 /postgresql/pgsql]$ll total 28 drwxr-xr-x. 2 postgres postgres 4096 nov 18 00:01 archive_log drwxrwxr-x. 2 postgres postgres 6 nov 17 15:51 backups drwxr-xr-x. 2 postgres postgres 4096 nov 17 16:43 bin drwx------. 19 postgres postgres 4096 nov 18 00:01 data drwxr-xr-x. 6 postgres postgres 4096 nov 15 16:14 include drwxr-xr-x. 4 postgres postgres 4096 nov 17 06:37 lib drwxr-xr-x. 2 postgres postgres 4096 nov 18 00:01 pg_log drwxrwxr-x. 6 postgres postgres 120 nov 18 00:00 pg_rman_backups drwxr-xr-x. 8 postgres postgres 4096 nov 15 16:14 share [postgres@node_206 /postgresql/pgsql]$rm -rf archive_log/* pg_rman_backups/* [postgres@node_206 /postgresql/pgsql]$ll total 24 drwxr-xr-x. 2 postgres postgres 6 nov 18 00:01 archive_log drwxrwxr-x. 2 postgres postgres 6 nov 17 15:51 backups drwxr-xr-x. 2 postgres postgres 4096 nov 17 16:43 bin drwx------. 19 postgres postgres 4096 nov 18 00:01 data drwxr-xr-x. 6 postgres postgres 4096 nov 15 16:14 include drwxr-xr-x. 4 postgres postgres 4096 nov 17 06:37 lib drwxr-xr-x. 2 postgres postgres 4096 nov 18 00:01 pg_log drwxrwxr-x. 2 postgres postgres 6 nov 18 00:01 pg_rman_backups drwxr-xr-x. 8 postgres postgres 4096 nov 15 16:14 share [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ls archive_log backups bin data include lib pg_log pg_rman_backups share [postgres@node_206 /postgresql/pgsql]$ll total 24 drwxr-xr-x. 2 postgres postgres 6 nov 18 00:01 archive_log drwxrwxr-x. 2 postgres postgres 6 nov 17 15:51 backups drwxr-xr-x. 2 postgres postgres 4096 nov 17 16:43 bin drwx------. 19 postgres postgres 4096 nov 18 00:01 data drwxr-xr-x. 6 postgres postgres 4096 nov 15 16:14 include drwxr-xr-x. 4 postgres postgres 4096 nov 17 06:37 lib drwxr-xr-x. 2 postgres postgres 4096 nov 18 00:01 pg_log drwxrwxr-x. 2 postgres postgres 6 nov 18 00:01 pg_rman_backups drwxr-xr-x. 8 postgres postgres 4096 nov 15 16:14 share [postgres@node_206 /postgresql/pgsql]$ll pg_rman_backups/ total 0 [postgres@node_206 /postgresql/pgsql]$ll archive_log/ total 0 [postgres@node_206 /postgresql/pgsql]$ll total 24 drwxr-xr-x. 2 postgres postgres 6 nov 18 00:01 archive_log drwxrwxr-x. 2 postgres postgres 6 nov 17 15:51 backups drwxr-xr-x. 2 postgres postgres 4096 nov 17 16:43 bin drwx------. 19 postgres postgres 4096 nov 18 00:01 data drwxr-xr-x. 6 postgres postgres 4096 nov 15 16:14 include drwxr-xr-x. 4 postgres postgres 4096 nov 17 06:37 lib drwxr-xr-x. 2 postgres postgres 4096 nov 18 00:01 pg_log drwxrwxr-x. 2 postgres postgres 6 nov 18 00:01 pg_rman_backups drwxr-xr-x. 8 postgres postgres 4096 nov 15 16:14 share [postgres@node_206 /postgresql/pgsql]$vim $pgdata/postgresql.conf [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ls archive_log backups bin data include lib pg_log pg_rman_backups share [postgres@node_206 /postgresql/pgsql]$ll total 24 drwxr-xr-x. 2 postgres postgres 6 nov 18 00:01 archive_log drwxrwxr-x. 2 postgres postgres 6 nov 17 15:51 backups drwxr-xr-x. 2 postgres postgres 4096 nov 17 16:43 bin drwx------. 19 postgres postgres 4096 nov 18 00:01 data drwxr-xr-x. 6 postgres postgres 4096 nov 15 16:14 include drwxr-xr-x. 4 postgres postgres 4096 nov 17 06:37 lib drwxr-xr-x. 2 postgres postgres 4096 nov 18 00:01 pg_log drwxrwxr-x. 2 postgres postgres 6 nov 18 00:01 pg_rman_backups drwxr-xr-x. 8 postgres postgres 4096 nov 15 16:14 share [postgres@node_206 /postgresql/pgsql]$ll pg_rman_backups/ total 0 [postgres@node_206 /postgresql/pgsql]$ll archive_log/ total 0 [postgres@node_206 /postgresql/pgsql]$ll total 24 drwxr-xr-x. 2 postgres postgres 6 nov 18 00:01 archive_log drwxrwxr-x. 2 postgres postgres 6 nov 17 15:51 backups drwxr-xr-x. 2 postgres postgres 4096 nov 17 16:43 bin drwx------. 19 postgres postgres 4096 nov 18 00:01 data drwxr-xr-x. 6 postgres postgres 4096 nov 15 16:14 include drwxr-xr-x. 4 postgres postgres 4096 nov 17 06:37 lib drwxr-xr-x. 2 postgres postgres 4096 nov 18 00:01 pg_log drwxrwxr-x. 2 postgres postgres 6 nov 18 00:01 pg_rman_backups drwxr-xr-x. 8 postgres postgres 4096 nov 15 16:14 share [postgres@node_206 /postgresql/pgsql]$vim $pgdata/postgresql.conf [postgres@node_206 /postgresql/pgsql]$pg_ctl restart waiting for server to shut down.... done server stopped waiting for server to start....2020-11-17 11:08:26.228 est [59464] log: 00000: starting postgresql 12.3 on x86_64-pc-linux-gnu, compiled by gcc (gcc) 4.8.5 20150623 (red hat 4.8.5-44), 64-bit 2020-11-17 11:08:26.228 est [59464] location: postmastermain, postmaster.c:998 2020-11-17 11:08:26.233 est [59464] log: 00000: listening on ipv4 address "0.0.0.0", port 5432 2020-11-17 11:08:26.233 est [59464] location: streamserverport, pqcomm.c:593 2020-11-17 11:08:26.233 est [59464] log: 00000: listening on ipv6 address "::", port 5432 2020-11-17 11:08:26.233 est [59464] location: streamserverport, pqcomm.c:593 2020-11-17 11:08:26.236 est [59464] log: 00000: listening on unix socket "/tmp/.s.pgsql.5432" 2020-11-17 11:08:26.236 est [59464] location: streamserverport, pqcomm.c:587 2020-11-17 11:08:26.293 est [59464] log: 00000: redirecting log output to logging collector process 2020-11-17 11:08:26.293 est [59464] hint: future log output will appear in directory "/postgresql/pgsql/pg_log". 2020-11-17 11:08:26.293 est [59464] location: syslogger_start, syslogger.c:675 done server started [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pwd /postgresql/pgsql [postgres@node_206 /postgresql/pgsql]$psql psql (12.3) type "help" for help. postgres=# \l list of databases name | owner | encoding | collate | ctype | access privileges -----------+----------+----------+-------------+-------------+----------------------- postgres | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | repmgr | repmgr | utf8 | en_us.utf-8 | en_us.utf-8 | template0 | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | =c/postgres + | | | | | postgres=ctc/postgres template1 | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | =c/postgres + | | | | | postgres=ctc/postgres (4 rows) postgres=# \q [postgres@node_206 /postgresql/pgsql]$pg_rman init -b /postgresql/pgsql/pg_rman_backups/ info: arclog_path is set to '/postgresql/pgsql/archive_log' info: srvlog_path is set to '/postgresql/pgsql/pg_log' [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$psql psql (12.3) type "help" for help. postgres=# create database test; create database postgres=# \c test you are now connected to database "test" as user "postgres". test=# create table test(id int, crt_time timestamp default clock_timestamp()); create table test=# insert into test (id) select n from generate_series(1,100) n; insert 0 100 test=# \q [postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -b /postgresql/pgsql/pg_rman_backups info: copying database files info: copying archived wal files info: backup complete info: please execute 'pg_rman validate' to verify the files are correctly copied. [postgres@node_206 /postgresql/pgsql]$pg_rman validate -b /postgresql/pgsql/pg_rman_backups info: validate: "2020-11-18 00:09:40" backup and archive log files by crc info: backup "2020-11-18 00:09:40" is valid [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$psql -d test psql (12.3) type "help" for help. test=# insert into test (id) select n from generate_series(101,110) n; insert 0 10 test=# \q [postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=incremental -b /postgresql/pgsql/pg_rman_backups info: copying database files info: copying archived wal files info: backup complete info: please execute 'pg_rman validate' to verify the files are correctly copied. [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-11-18 00:10:03 2020-11-18 00:10:05 incr 33mb 6 done 2020-11-18 00:09:40 2020-11-18 00:09:42 full 64mb 6 ok [postgres@node_206 /postgresql/pgsql]$pg_rman validate -b /postgresql/pgsql/pg_rman_backups info: validate: "2020-11-18 00:10:03" backup and archive log files by crc info: backup "2020-11-18 00:10:03" is valid [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-11-18 00:10:03 2020-11-18 00:10:05 incr 33mb 6 ok 2020-11-18 00:09:40 2020-11-18 00:09:42 full 64mb 6 ok [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$psql -d test psql (12.3) type "help" for help. test=# create table test2(like test); create table test=# insert into test2 (id) select n from generate_series(1,100) n; insert 0 100 test=# \q [postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -b /postgresql/pgsql/pg_rman_backups info: copying database files info: copying archived wal files info: backup complete info: please execute 'pg_rman validate' to verify the files are correctly copied. [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-11-18 00:10:49 2020-11-18 00:10:51 full 64mb 6 done 2020-11-18 00:10:03 2020-11-18 00:10:05 incr 33mb 6 ok 2020-11-18 00:09:40 2020-11-18 00:09:42 full 64mb 6 ok [postgres@node_206 /postgresql/pgsql]$pg_rman validate -b /postgresql/pgsql/pg_rman_backups info: validate: "2020-11-18 00:10:49" backup and archive log files by crc info: backup "2020-11-18 00:10:49" is valid [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-11-18 00:10:49 2020-11-18 00:10:51 full 64mb 6 ok 2020-11-18 00:10:03 2020-11-18 00:10:05 incr 33mb 6 ok 2020-11-18 00:09:40 2020-11-18 00:09:42 full 64mb 6 ok [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman delete -f 2020-11-18 00:10:03 error: required parameter not specified: backup_path (-b, --backup-path) [postgres@node_206 /postgresql/pgsql]$pg_rman delete -f 2020-11-18 00:10:03 -b /postgresql/pgsql/pg_rman_backups/ warning: using force option will make some of the remaining backups unusable detail: any remaining incremental backups that are older than the oldest available full backup cannot be restored. info: delete the backup with start time: "2020-11-18 00:10:03" info: delete the backup with start time: "2020-11-18 00:09:40" [postgres@node_206 /postgresql/pgsql]$pg_rman purge -b /postgresql/pgsql/pg_rman_backups/ info: deleted backup "2020-11-18 00:10:03" is purged info: deleted backup "2020-11-18 00:09:40" is purged [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-11-18 00:10:49 2020-11-18 00:10:51 full 64mb 6 ok [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$psql psql (12.3) type "help" for help. postgres=# \l list of databases name | owner | encoding | collate | ctype | access privileges -----------+----------+----------+-------------+-------------+----------------------- postgres | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | repmgr | repmgr | utf8 | en_us.utf-8 | en_us.utf-8 | template0 | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | =c/postgres + | | | | | postgres=ctc/postgres template1 | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | =c/postgres + | | | | | postgres=ctc/postgres test | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | (5 rows) postgres=# drop database test; drop database postgres=# \q [postgres@node_206 /postgresql/pgsql]$pg_ctl stop waiting for server to shut down.... done server stopped [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/data/ --recovery-target-time='2020-11-18 00:10:49' error: required parameter not specified: arclog_path (-a, --arclog-path) [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/data/ --recovery-target-time='2020-11-18 00:10:49' -a /postgresql/pgsql/archive_log/ error: required parameter not specified: srvlog_path (-s, --srvlog-path) [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/data/ --recovery-target-time='2020-11-18 00:10:49' -a /postgresql/pgsql/archive_log/ -s /postgresql/pgsql/pg_log/ error: could not open file "/postgresql/pgsql/data//pg_rman.ini": no such file or directory [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/data/ --recovery-target-time='2020-11-18 00:10:49' [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-11-18 00:10:49' error: cannot do restore detail: there is no valid full backup which can be used for given recovery condition. [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-11-18 00:10:49 2020-11-18 00:10:51 full 64mb 6 ok [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-11-18 00:10:00\' error: cannot do restore detail: there is no valid full backup which can be used for given recovery condition. [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-11-18 00:10:00' error: cannot do restore detail: there is no valid full backup which can be used for given recovery condition. [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-11-18' error: cannot do restore detail: there is no valid full backup which can be used for given recovery condition. [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ info: the recovery target timeline id is not given info: use timeline id of current database cluster as recovery target: 6 info: calculating timeline branches to be used to recovery target point info: searching latest full backup which can be used as restore start point info: found the full backup can be used as base in recovery: "2020-11-18 00:10:49" info: copying online wal files and server log files info: clearing restore destination info: validate: "2020-11-18 00:10:49" backup and archive log files by size info: backup "2020-11-18 00:10:49" is valid info: restoring database files from the full mode backup "2020-11-18 00:10:49" info: searching incremental backup to be restored info: searching backup which contained archived wal files to be restored info: backup "2020-11-18 00:10:49" is valid info: restoring wal files from backup "2020-11-18 00:10:49" info: restoring online wal files and server log files info: add recovery related options to postgresql.conf info: generating recovery.signal info: restore complete hint: recovery will start automatically when the postgresql server is started. [postgres@node_206 /postgresql/pgsql]$rm -f data/recovery.signal [postgres@node_206 /postgresql/pgsql]$pg_ctl start waiting for server to start....2020-11-17 11:14:46.684 est [59594] log: 00000: starting postgresql 12.3 on x86_64-pc-linux-gnu, compiled by gcc (gcc) 4.8.5 20150623 (red hat 4.8.5-44), 64-bit 2020-11-17 11:14:46.684 est [59594] location: postmastermain, postmaster.c:998 2020-11-17 11:14:46.689 est [59594] log: 00000: listening on ipv4 address "0.0.0.0", port 5432 2020-11-17 11:14:46.689 est [59594] location: streamserverport, pqcomm.c:593 2020-11-17 11:14:46.689 est [59594] log: 00000: listening on ipv6 address "::", port 5432 2020-11-17 11:14:46.689 est [59594] location: streamserverport, pqcomm.c:593 2020-11-17 11:14:46.691 est [59594] log: 00000: listening on unix socket "/tmp/.s.pgsql.5432" 2020-11-17 11:14:46.691 est [59594] location: streamserverport, pqcomm.c:587 2020-11-17 11:14:46.732 est [59594] log: 00000: redirecting log output to logging collector process 2020-11-17 11:14:46.732 est [59594] hint: future log output will appear in directory "/postgresql/pgsql/pg_log". 2020-11-17 11:14:46.732 est [59594] location: syslogger_start, syslogger.c:675 stopped waiting pg_ctl: could not start server examine the log output. [postgres@node_206 /postgresql/pgsql]$touch data/recovery.signal [postgres@node_206 /postgresql/pgsql]$pg_ctl start waiting for server to start....2020-11-17 11:15:04.292 est [59600] log: 00000: starting postgresql 12.3 on x86_64-pc-linux-gnu, compiled by gcc (gcc) 4.8.5 20150623 (red hat 4.8.5-44), 64-bit 2020-11-17 11:15:04.292 est [59600] location: postmastermain, postmaster.c:998 2020-11-17 11:15:04.293 est [59600] log: 00000: listening on ipv4 address "0.0.0.0", port 5432 2020-11-17 11:15:04.293 est [59600] location: streamserverport, pqcomm.c:593 2020-11-17 11:15:04.293 est [59600] log: 00000: listening on ipv6 address "::", port 5432 2020-11-17 11:15:04.293 est [59600] location: streamserverport, pqcomm.c:593 2020-11-17 11:15:04.296 est [59600] log: 00000: listening on unix socket "/tmp/.s.pgsql.5432" 2020-11-17 11:15:04.296 est [59600] location: streamserverport, pqcomm.c:587 2020-11-17 11:15:04.347 est [59600] log: 00000: redirecting log output to logging collector process 2020-11-17 11:15:04.347 est [59600] hint: future log output will appear in directory "/postgresql/pgsql/pg_log". 2020-11-17 11:15:04.347 est [59600] location: syslogger_start, syslogger.c:675 done server started [postgres@node_206 /postgresql/pgsql]$psql psql (12.3) type "help" for help. postgres=# \l list of databases name | owner | encoding | collate | ctype | access privileges -----------+----------+----------+-------------+-------------+----------------------- postgres | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | repmgr | repmgr | utf8 | en_us.utf-8 | en_us.utf-8 | template0 | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | =c/postgres + | | | | | postgres=ctc/postgres template1 | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | =c/postgres + | | | | | postgres=ctc/postgres (4 rows) postgres=# \q [postgres@node_206 /postgresql/pgsql]$pg_rman error: required parameter not specified: backup_path (-b, --backup-path) [postgres@node_206 /postgresql/pgsql]$pg_rman --help pg_rman manage backup/recovery of postgresql database. usage: pg_rman option init pg_rman option backup pg_rman option restore pg_rman option show [date] pg_rman option show detail [date] pg_rman option validate [date] pg_rman option delete date pg_rman option purge common options: -d, --pgdata=path location of the database storage area -a, --arclog-path=path location of archive wal storage area -s, --srvlog-path=path location of server log storage area -b, --backup-path=path location of the backup storage area -c, --check show what would have been done -v, --verbose show what detail messages -p, --progress show progress of processed files backup options: -b, --backup-mode=mode full, incremental, or archive -s, --with-serverlog also backup server log files -z, --compress-data compress data backup with zlib -c, --smooth-checkpoint do smooth checkpoint before backup -f, --full-backup-on-error switch to full backup mode if pg_rman cannot find validate full backup on current timeline note: this option is only used in --backup-mode=incremental or archive. --keep-data-generations=num keep num generations of full data backup --keep-data-days=num keep enough data backup to recover to n days ago --keep-arclog-files=num keep num of archived wal --keep-arclog-days=day keep archived wal modified in day days --keep-srvlog-files=num keep num of serverlogs --keep-srvlog-days=day keep serverlog modified in day days --standby-host=hostname standby host when taking backup from standby --standby-port=port standby port when taking backup from standby restore options: --recovery-target-time time stamp up to which recovery will proceed --recovery-target-xid transaction id up to which recovery will proceed --recovery-target-inclusive whether we stop just after the recovery target --recovery-target-timeline recovering into a particular timeline --hard-copy copying archivelog not symbolic link catalog options: -a, --show-all show deleted backup too delete options: -f, --force forcibly delete backup older than given date connection options: -d, --dbname=dbname database to connect -h, --host=hostname database server host or socket directory -p, --port=port database server port -u, --username=username user name to connect as -w, --no-password never prompt for password -w, --password force password prompt generic options: -q, --quiet don't show any info or debug messages --debug show debug messages --help show this help, then exit --version output version information, then exit read the website for details. <http://github.com/ossc-db/pg_rman> report bugs to <http://github.com/ossc-db/pg_rman/issues>. [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pwd /postgresql/pgsql [postgres@node_206 /postgresql/pgsql]$ls archive_log backups bin data include lib pg_log pg_rman_backups share [postgres@node_206 /postgresql/pgsql]$vim $pgdata/postgresql.conf catalog options: -a, --show-all show deleted backup too delete options: -f, --force forcibly delete backup older than given date connection options: -d, --dbname=dbname database to connect -h, --host=hostname database server host or socket directory -p, --port=port database server port -u, --username=username user name to connect as -w, --no-password never prompt for password -w, --password force password prompt generic options: -q, --quiet don't show any info or debug messages --debug show debug messages --help show this help, then exit --version output version information, then exit read the website for details. <http://github.com/ossc-db/pg_rman> report bugs to <http://github.com/ossc-db/pg_rman/issues>. [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pwd /postgresql/pgsql [postgres@node_206 /postgresql/pgsql]$ls archive_log backups bin data include lib pg_log pg_rman_backups share [postgres@node_206 /postgresql/pgsql]$vim $pgdata/postgresql.conf [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-11-18 00:10:49 2020-11-18 00:10:51 full 64mb 6 ok [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ll total 28 drwxr-xr-x. 2 postgres postgres 4096 nov 18 00:15 archive_log drwxrwxr-x. 2 postgres postgres 6 nov 17 15:51 backups drwxr-xr-x. 2 postgres postgres 4096 nov 17 16:43 bin drwx------. 19 postgres postgres 4096 nov 18 02:41 data drwxr-xr-x. 6 postgres postgres 4096 nov 15 16:14 include drwxr-xr-x. 4 postgres postgres 4096 nov 17 06:37 lib drwxr-xr-x. 2 postgres postgres 4096 nov 18 00:15 pg_log drwxrwxr-x. 5 postgres postgres 104 nov 18 00:09 pg_rman_backups drwxr-xr-x. 8 postgres postgres 4096 nov 15 16:14 share [postgres@node_206 /postgresql/pgsql]$vim $pgdata/postgresql.conf --version output version information, then exit read the website for details. <http://github.com/ossc-db/pg_rman> report bugs to <http://github.com/ossc-db/pg_rman/issues>. [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pwd /postgresql/pgsql [postgres@node_206 /postgresql/pgsql]$ls archive_log backups bin data include lib pg_log pg_rman_backups share [postgres@node_206 /postgresql/pgsql]$vim $pgdata/postgresql.conf [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-11-18 00:10:49 2020-11-18 00:10:51 full 64mb 6 ok [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ll total 28 drwxr-xr-x. 2 postgres postgres 4096 nov 18 00:15 archive_log drwxrwxr-x. 2 postgres postgres 6 nov 17 15:51 backups drwxr-xr-x. 2 postgres postgres 4096 nov 17 16:43 bin drwx------. 19 postgres postgres 4096 nov 18 02:41 data drwxr-xr-x. 6 postgres postgres 4096 nov 15 16:14 include drwxr-xr-x. 4 postgres postgres 4096 nov 17 06:37 lib drwxr-xr-x. 2 postgres postgres 4096 nov 18 00:15 pg_log drwxrwxr-x. 5 postgres postgres 104 nov 18 00:09 pg_rman_backups drwxr-xr-x. 8 postgres postgres 4096 nov 15 16:14 share [postgres@node_206 /postgresql/pgsql]$vim $pgdata/postgresql.conf [postgres@node_206 /postgresql/pgsql]$pg_ctl restart -m fast waiting for server to shut down.... done server stopped waiting for server to start....2020-11-17 13:41:36.369 est [60239] log: 00000: starting postgresql 12.3 on x86_64-pc-linux-gnu, compiled by gcc (gcc) 4.8.5 20150623 (red hat 4.8.5-44), 64-bit 2020-11-17 13:41:36.369 est [60239] location: postmastermain, postmaster.c:998 2020-11-17 13:41:36.371 est [60239] log: 00000: listening on ipv4 address "0.0.0.0", port 5432 2020-11-17 13:41:36.371 est [60239] location: streamserverport, pqcomm.c:593 2020-11-17 13:41:36.371 est [60239] log: 00000: listening on ipv6 address "::", port 5432 2020-11-17 13:41:36.371 est [60239] location: streamserverport, pqcomm.c:593 2020-11-17 13:41:36.377 est [60239] log: 00000: listening on unix socket "/tmp/.s.pgsql.5432" 2020-11-17 13:41:36.377 est [60239] location: streamserverport, pqcomm.c:587 2020-11-17 13:41:36.466 est [60239] log: 00000: redirecting log output to logging collector process 2020-11-17 13:41:36.466 est [60239] hint: future log output will appear in directory "/postgresql/pgsql/pg_log". 2020-11-17 13:41:36.466 est [60239] location: syslogger_start, syslogger.c:675 done server started [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ls archive_log backups bin data include lib pg_log pg_rman_backups share [postgres@node_206 /postgresql/pgsql]$ll total 28 drwxr-xr-x. 2 postgres postgres 4096 nov 18 02:41 archive_log drwxrwxr-x. 2 postgres postgres 6 nov 17 15:51 backups drwxr-xr-x. 2 postgres postgres 4096 nov 17 16:43 bin drwx------. 19 postgres postgres 4096 nov 18 02:41 data drwxr-xr-x. 6 postgres postgres 4096 nov 15 16:14 include drwxr-xr-x. 4 postgres postgres 4096 nov 17 06:37 lib drwxr-xr-x. 2 postgres postgres 4096 nov 18 02:41 pg_log drwxrwxr-x. 5 postgres postgres 104 nov 18 00:09 pg_rman_backups drwxr-xr-x. 8 postgres postgres 4096 nov 15 16:14 share [postgres@node_206 /postgresql/pgsql]$rm -rf archive_log/* [postgres@node_206 /postgresql/pgsql]$rm -rf pg_rman_backups/* [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$vim $pgdata/postgresql.conf 2020-11-17 13:41:36.369 est [60239] location: postmastermain, postmaster.c:998 2020-11-17 13:41:36.371 est [60239] log: 00000: listening on ipv4 address "0.0.0.0", port 5432 2020-11-17 13:41:36.371 est [60239] location: streamserverport, pqcomm.c:593 2020-11-17 13:41:36.371 est [60239] log: 00000: listening on ipv6 address "::", port 5432 2020-11-17 13:41:36.371 est [60239] location: streamserverport, pqcomm.c:593 2020-11-17 13:41:36.377 est [60239] log: 00000: listening on unix socket "/tmp/.s.pgsql.5432" 2020-11-17 13:41:36.377 est [60239] location: streamserverport, pqcomm.c:587 2020-11-17 13:41:36.466 est [60239] log: 00000: redirecting log output to logging collector process 2020-11-17 13:41:36.466 est [60239] hint: future log output will appear in directory "/postgresql/pgsql/pg_log". 2020-11-17 13:41:36.466 est [60239] location: syslogger_start, syslogger.c:675 done server started [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ls archive_log backups bin data include lib pg_log pg_rman_backups share [postgres@node_206 /postgresql/pgsql]$ll total 28 drwxr-xr-x. 2 postgres postgres 4096 nov 18 02:41 archive_log drwxrwxr-x. 2 postgres postgres 6 nov 17 15:51 backups drwxr-xr-x. 2 postgres postgres 4096 nov 17 16:43 bin drwx------. 19 postgres postgres 4096 nov 18 02:41 data drwxr-xr-x. 6 postgres postgres 4096 nov 15 16:14 include drwxr-xr-x. 4 postgres postgres 4096 nov 17 06:37 lib drwxr-xr-x. 2 postgres postgres 4096 nov 18 02:41 pg_log drwxrwxr-x. 5 postgres postgres 104 nov 18 00:09 pg_rman_backups drwxr-xr-x. 8 postgres postgres 4096 nov 15 16:14 share [postgres@node_206 /postgresql/pgsql]$rm -rf archive_log/* [postgres@node_206 /postgresql/pgsql]$rm -rf pg_rman_backups/* [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$vim $pgdata/postgresql.conf [postgres@node_206 /postgresql/pgsql]$pg_ctl restart -m fast waiting for server to shut down.... done server stopped waiting for server to start....2020-11-17 13:41:51.227 est [60254] log: 00000: starting postgresql 12.3 on x86_64-pc-linux-gnu, compiled by gcc (gcc) 4.8.5 20150623 (red hat 4.8.5-44), 64-bit 2020-11-17 13:41:51.227 est [60254] location: postmastermain, postmaster.c:998 2020-11-17 13:41:51.228 est [60254] log: 00000: listening on ipv4 address "0.0.0.0", port 5432 2020-11-17 13:41:51.228 est [60254] location: streamserverport, pqcomm.c:593 2020-11-17 13:41:51.228 est [60254] log: 00000: listening on ipv6 address "::", port 5432 2020-11-17 13:41:51.228 est [60254] location: streamserverport, pqcomm.c:593 2020-11-17 13:41:51.239 est [60254] log: 00000: listening on unix socket "/tmp/.s.pgsql.5432" 2020-11-17 13:41:51.239 est [60254] location: streamserverport, pqcomm.c:587 2020-11-17 13:41:51.372 est [60254] log: 00000: redirecting log output to logging collector process 2020-11-17 13:41:51.372 est [60254] hint: future log output will appear in directory "/postgresql/pgsql/pg_log". 2020-11-17 13:41:51.372 est [60254] location: syslogger_start, syslogger.c:675 done server started [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$psql psql (12.3) type "help" for help. postgres=# \l list of databases name | owner | encoding | collate | ctype | access privileges -----------+----------+----------+-------------+-------------+----------------------- postgres | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | repmgr | repmgr | utf8 | en_us.utf-8 | en_us.utf-8 | template0 | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | =c/postgres + | | | | | postgres=ctc/postgres template1 | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | =c/postgres + | | | | | postgres=ctc/postgres (4 rows) postgres=# \q [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$history |grep pg_rman |grep init 519 pg_rman init -b /postgresql/pgsql/pg_rman_backups/ 538 pg_rman init -b /postgresql/pgsql/pg_rman_backups 544 pg_rman init -b /postgresql/pgsql/pg_rman_backups 725 ll /postgresql/pgsql/pg_rman_backups/*init 926 ll /postgresql/pgsql/pg_rman_backups/*init 927 pg_rman init -b /postgresql/pgsql/pg_rman_backups 976 pg_rman init -b 977 pg_rman init 980 pg_rman init 981 pg_rman init -b /postgresql/pgsql/pg_rman_backups/ 1029 pg_rman init -b /postgresql/pgsql/pg_rman_backups/ 1102 pg_rman init -b /postgresql/pgsql/pg_rman_backups/ 1152 history |grep pg_rman |grep init [postgres@node_206 /postgresql/pgsql]$pg_rman init -b /postgresql/pgsql/pg_rman_backups/ info: arclog_path is set to '/postgresql/pgsql/archive_log' info: srvlog_path is set to '/postgresql/pgsql/pg_log' [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$psql psql (12.3) type "help" for help. postgres=# create database test; create database postgres=# \c test you are now connected to database "test" as user "postgres". test=# create table test(id int, crt_time timestamp default clock_timestamp()); create table test=# insert into test(id) select n from generate_series test-# (1,1000) n; insert 0 1000 test=# \q [postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -b /postgresql/pgsql/pg_rman_backups info: copying database files info: copying archived wal files info: backup complete info: please execute 'pg_rman validate' to verify the files are correctly copied. [postgres@node_206 /postgresql/pgsql]$pg_rman validate -b /postgresql/pgsql/pg_rman_backups info: validate: "2020-11-18 02:43:17" backup and archive log files by crc info: backup "2020-11-18 02:43:17" is valid [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-11-18 02:43:17 2020-11-18 02:43:19 full 64mb 10 ok [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ls archive_log backups bin data include lib pg_log pg_rman_backups share [postgres@node_206 /postgresql/pgsql]$cd pg_rman_backups/ [postgres@node_206 /postgresql/pgsql/pg_rman_backups]$ls 20201118 backup pg_rman.ini system_identifier timeline_history [postgres@node_206 /postgresql/pgsql/pg_rman_backups]$ll total 8 drwx------. 3 postgres postgres 20 nov 18 02:43 20201118 drwx------. 4 postgres postgres 34 nov 18 02:42 backup -rw-rw-r--. 1 postgres postgres 84 nov 18 02:42 pg_rman.ini -rw-rw-r--. 1 postgres postgres 40 nov 18 02:42 system_identifier drwx------. 2 postgres postgres 6 nov 18 02:42 timeline_history [postgres@node_206 /postgresql/pgsql/pg_rman_backups]$vim *ini test=# \q [postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -b /postgresql/pgsql/pg_rman_backups info: copying database files info: copying archived wal files info: backup complete info: please execute 'pg_rman validate' to verify the files are correctly copied. [postgres@node_206 /postgresql/pgsql]$pg_rman validate -b /postgresql/pgsql/pg_rman_backups info: validate: "2020-11-18 02:43:17" backup and archive log files by crc info: backup "2020-11-18 02:43:17" is valid [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-11-18 02:43:17 2020-11-18 02:43:19 full 64mb 10 ok [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ls archive_log backups bin data include lib pg_log pg_rman_backups share [postgres@node_206 /postgresql/pgsql]$cd pg_rman_backups/ [postgres@node_206 /postgresql/pgsql/pg_rman_backups]$ls 20201118 backup pg_rman.ini system_identifier timeline_history [postgres@node_206 /postgresql/pgsql/pg_rman_backups]$ll total 8 drwx------. 3 postgres postgres 20 nov 18 02:43 20201118 drwx------. 4 postgres postgres 34 nov 18 02:42 backup -rw-rw-r--. 1 postgres postgres 84 nov 18 02:42 pg_rman.ini -rw-rw-r--. 1 postgres postgres 40 nov 18 02:42 system_identifier drwx------. 2 postgres postgres 6 nov 18 02:42 timeline_history [postgres@node_206 /postgresql/pgsql/pg_rman_backups]$vim *ini [postgres@node_206 /postgresql/pgsql/pg_rman_backups]$ [postgres@node_206 /postgresql/pgsql/pg_rman_backups]$ [postgres@node_206 /postgresql/pgsql/pg_rman_backups]$ [postgres@node_206 /postgresql/pgsql/pg_rman_backups]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-11-18 02:43:17 2020-11-18 02:43:19 full 64mb 10 ok [postgres@node_206 /postgresql/pgsql/pg_rman_backups]$ [postgres@node_206 /postgresql/pgsql/pg_rman_backups]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ detail ====================================================================================================================== starttime endtime mode data arclog srvlog total compressed curtli parenttli status ====================================================================================================================== 2020-11-18 02:43:17 2020-11-18 02:43:19 full 44mb 33mb ---- 64mb false 10 0 ok [postgres@node_206 /postgresql/pgsql/pg_rman_backups]$ [postgres@node_206 /postgresql/pgsql/pg_rman_backups]$ [postgres@node_206 /postgresql/pgsql/pg_rman_backups]$ [postgres@node_206 /postgresql/pgsql/pg_rman_backups]$ [postgres@node_206 /postgresql/pgsql/pg_rman_backups]$psql -u postgres -d test psql (12.3) type "help" for help. test=# \dt list of relations schema | name | type | owner --------+------+-------+---------- public | test | table | postgres (1 row) test=# select count(*) from test; count ------- 1000 (1 row) test=# insert into test (id ) select n from generate_series(1001, 2000) n ; insert 0 1000 test=# \q [postgres@node_206 /postgresql/pgsql/pg_rman_backups]$pg_rman backup -bi -b /postgresql/pgsql/pg_rman_backups info: copying database files info: copying archived wal files info: backup complete info: please execute 'pg_rman validate' to verify the files are correctly copied. info: start deleting old archived wal files from arclog_path (keep days = 10) info: the threshold timestamp calculated by keep days is "2020-11-08 00:00:00" info: start deleting old backup (keep generations = 3 and keep after = 2020-09-19 00:00:00) info: does not include the backup just taken info: backup "2020-11-18 02:43:17" should be kept detail: this is the 1st latest full backup. [postgres@node_206 /postgresql/pgsql/pg_rman_backups]$pg_rman validate -b /postgresql/pgsql/pg_rman_backups info: validate: "2020-11-18 02:46:41" backup and archive log files by crc info: backup "2020-11-18 02:46:41" is valid [postgres@node_206 /postgresql/pgsql/pg_rman_backups]$date wed nov 18 02:48:04 cst 2020 (reverse-i-search)`': ^c [postgres@node_206 /postgresql/pgsql/pg_rman_backups]$psql psql (12.3) type "help" for help. postgres=# select now(); now ------------------------------- 2020-11-18 02:48:18.215429+08 (1 row) postgres=# \q [postgres@node_206 /postgresql/pgsql/pg_rman_backups]$exit logout [root@node_206 ~]# history | grep ntpdate 467 history | grep ntpdate [root@node_206 ~]# ntpdate time.ntp.org error resolving time.ntp.org: name or service not known (-2) 18 nov 02:49:19 ntpdate[60350]: can't find host time.ntp.org: name or service not known (-2) 18 nov 02:49:19 ntpdate[60350]: no servers can be used, exiting [root@node_206 ~]# ping baidu.com ping baidu.com (220.181.38.148) 56(84) bytes of data. 64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=1 ttl=50 time=61.3 ms ^c --- baidu.com ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 61.374/61.374/61.374/0.000 ms [root@node_206 ~]# ntpdate 0.cn.pool.ntp.org 20 dec 22:36:38 ntpdate[60355]: step time server 5.79.108.34 offset 2836002.583561 sec [root@node_206 ~]# [root@node_206 ~]# date sun dec 20 22:36:40 cst 2020 [root@node_206 ~]# vim /etc/crontab postgres=# select now(); now ------------------------------- 2020-11-18 02:48:18.215429+08 (1 row) postgres=# \q [postgres@node_206 /postgresql/pgsql/pg_rman_backups]$exit logout [root@node_206 ~]# history | grep ntpdate 467 history | grep ntpdate [root@node_206 ~]# ntpdate time.ntp.org error resolving time.ntp.org: name or service not known (-2) 18 nov 02:49:19 ntpdate[60350]: can't find host time.ntp.org: name or service not known (-2) 18 nov 02:49:19 ntpdate[60350]: no servers can be used, exiting [root@node_206 ~]# ping baidu.com ping baidu.com (220.181.38.148) 56(84) bytes of data. 64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=1 ttl=50 time=61.3 ms ^c --- baidu.com ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 61.374/61.374/61.374/0.000 ms [root@node_206 ~]# ntpdate 0.cn.pool.ntp.org 20 dec 22:36:38 ntpdate[60355]: step time server 5.79.108.34 offset 2836002.583561 sec [root@node_206 ~]# [root@node_206 ~]# date sun dec 20 22:36:40 cst 2020 [root@node_206 ~]# vim /etc/crontab [root@node_206 ~]# lsd -bash: lsd: command not found [root@node_206 ~]# [root@node_206 ~]# ls anaconda-ks.cfg [root@node_206 ~]# date sun dec 20 22:37:13 cst 2020 [root@node_206 ~]# psql -bash: psql: command not found [root@node_206 ~]# ip ro show default via 192.168.0.1 dev eth0 proto static metric 100 192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.206 metric 100 [root@node_206 ~]# psql -bash: psql: command not found [root@node_206 ~]# su - postgres last login: tue nov 17 22:47:52 cst 2020 on pts/1 [postgres@node_206 ~]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-11-18 02:46:41 2020-11-18 02:46:43 incr 59kb 10 ok 2020-11-18 02:43:17 2020-11-18 02:43:19 full 64mb 10 ok [postgres@node_206 ~]$ [postgres@node_206 ~]$vim $pgdata/postgresql.conf [root@node_206 ~]# ntpdate 0.cn.pool.ntp.org 20 dec 22:36:38 ntpdate[60355]: step time server 5.79.108.34 offset 2836002.583561 sec [root@node_206 ~]# [root@node_206 ~]# date sun dec 20 22:36:40 cst 2020 [root@node_206 ~]# vim /etc/crontab [root@node_206 ~]# lsd -bash: lsd: command not found [root@node_206 ~]# [root@node_206 ~]# ls anaconda-ks.cfg [root@node_206 ~]# date sun dec 20 22:37:13 cst 2020 [root@node_206 ~]# psql -bash: psql: command not found [root@node_206 ~]# ip ro show default via 192.168.0.1 dev eth0 proto static metric 100 192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.206 metric 100 [root@node_206 ~]# psql -bash: psql: command not found [root@node_206 ~]# su - postgres last login: tue nov 17 22:47:52 cst 2020 on pts/1 [postgres@node_206 ~]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-11-18 02:46:41 2020-11-18 02:46:43 incr 59kb 10 ok 2020-11-18 02:43:17 2020-11-18 02:43:19 full 64mb 10 ok [postgres@node_206 ~]$ [postgres@node_206 ~]$vim $pgdata/postgresql.conf [postgres@node_206 ~]$pg_ctl restart -m fast waiting for server to shut down.... done server stopped waiting for server to start....2020-12-20 09:37:46.967 est [60411] log: 00000: starting postgresql 12.3 on x86_64-pc-linux-gnu, compiled by gcc (gcc) 4.8.5 20150623 (red hat 4.8.5-44), 64-bit 2020-12-20 09:37:46.967 est [60411] location: postmastermain, postmaster.c:998 2020-12-20 09:37:46.969 est [60411] log: 00000: listening on ipv4 address "0.0.0.0", port 5432 2020-12-20 09:37:46.969 est [60411] location: streamserverport, pqcomm.c:593 2020-12-20 09:37:46.969 est [60411] log: 00000: listening on ipv6 address "::", port 5432 2020-12-20 09:37:46.969 est [60411] location: streamserverport, pqcomm.c:593 2020-12-20 09:37:46.971 est [60411] log: 00000: listening on unix socket "/tmp/.s.pgsql.5432" 2020-12-20 09:37:46.971 est [60411] location: streamserverport, pqcomm.c:587 2020-12-20 09:37:47.014 est [60411] log: 00000: redirecting log output to logging collector process 2020-12-20 09:37:47.014 est [60411] hint: future log output will appear in directory "/postgresql/pgsql/pg_log". 2020-12-20 09:37:47.014 est [60411] location: syslogger_start, syslogger.c:675 done server started [postgres@node_206 ~]$ [postgres@node_206 ~]$ls postgres_dba test.dmp [postgres@node_206 ~]$ll total 4 drwxrwxr-x. 10 postgres postgres 198 nov 17 03:00 postgres_dba -rw-rw-r--. 1 postgres postgres 1275 nov 17 14:08 test.dmp [postgres@node_206 ~]$cd /postgresql/p -bash: cd: /postgresql/p: no such file or directory [postgres@node_206 ~]$cd /postgresql/pgsql/ [postgres@node_206 /postgresql/pgsql]$ls archive_log backups bin data include lib pg_log pg_rman_backups share [postgres@node_206 /postgresql/pgsql]$ll total 28 drwxr-xr-x. 2 postgres postgres 262 dec 20 22:37 archive_log drwxrwxr-x. 2 postgres postgres 6 nov 17 15:51 backups drwxr-xr-x. 2 postgres postgres 4096 nov 17 16:43 bin drwx------. 19 postgres postgres 4096 dec 20 22:37 data drwxr-xr-x. 6 postgres postgres 4096 nov 15 16:14 include drwxr-xr-x. 4 postgres postgres 4096 nov 17 06:37 lib drwxr-xr-x. 2 postgres postgres 4096 dec 20 22:37 pg_log drwxrwxr-x. 5 postgres postgres 104 nov 18 02:45 pg_rman_backups drwxr-xr-x. 8 postgres postgres 4096 nov 15 16:14 share [postgres@node_206 /postgresql/pgsql]$rm -rf archive_log/* pg_rman_backups/* [postgres@node_206 /postgresql/pgsql]$ll total 28 drwxr-xr-x. 2 postgres postgres 6 dec 20 22:37 archive_log drwxrwxr-x. 2 postgres postgres 6 nov 17 15:51 backups drwxr-xr-x. 2 postgres postgres 4096 nov 17 16:43 bin drwx------. 19 postgres postgres 4096 dec 20 22:37 data drwxr-xr-x. 6 postgres postgres 4096 nov 15 16:14 include drwxr-xr-x. 4 postgres postgres 4096 nov 17 06:37 lib drwxr-xr-x. 2 postgres postgres 4096 dec 20 22:37 pg_log drwxrwxr-x. 2 postgres postgres 6 dec 20 22:37 pg_rman_backups drwxr-xr-x. 8 postgres postgres 4096 nov 15 16:14 share [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ll backups/ total 0 [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$vim $pgdata/postgresql.conf [postgres@node_206 /postgresql/pgsql]$ls archive_log backups bin data include lib pg_log pg_rman_backups share [postgres@node_206 /postgresql/pgsql]$ll total 28 drwxr-xr-x. 2 postgres postgres 262 dec 20 22:37 archive_log drwxrwxr-x. 2 postgres postgres 6 nov 17 15:51 backups drwxr-xr-x. 2 postgres postgres 4096 nov 17 16:43 bin drwx------. 19 postgres postgres 4096 dec 20 22:37 data drwxr-xr-x. 6 postgres postgres 4096 nov 15 16:14 include drwxr-xr-x. 4 postgres postgres 4096 nov 17 06:37 lib drwxr-xr-x. 2 postgres postgres 4096 dec 20 22:37 pg_log drwxrwxr-x. 5 postgres postgres 104 nov 18 02:45 pg_rman_backups drwxr-xr-x. 8 postgres postgres 4096 nov 15 16:14 share [postgres@node_206 /postgresql/pgsql]$rm -rf archive_log/* pg_rman_backups/* [postgres@node_206 /postgresql/pgsql]$ll total 28 drwxr-xr-x. 2 postgres postgres 6 dec 20 22:37 archive_log drwxrwxr-x. 2 postgres postgres 6 nov 17 15:51 backups drwxr-xr-x. 2 postgres postgres 4096 nov 17 16:43 bin drwx------. 19 postgres postgres 4096 dec 20 22:37 data drwxr-xr-x. 6 postgres postgres 4096 nov 15 16:14 include drwxr-xr-x. 4 postgres postgres 4096 nov 17 06:37 lib drwxr-xr-x. 2 postgres postgres 4096 dec 20 22:37 pg_log drwxrwxr-x. 2 postgres postgres 6 dec 20 22:37 pg_rman_backups drwxr-xr-x. 8 postgres postgres 4096 nov 15 16:14 share [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ll backups/ total 0 [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$vim $pgdata/postgresql.conf [postgres@node_206 /postgresql/pgsql]$pg_ctl restart -m fast waiting for server to shut down.... done server stopped waiting for server to start....2020-12-20 09:38:08.353 est [60437] log: 00000: starting postgresql 12.3 on x86_64-pc-linux-gnu, compiled by gcc (gcc) 4.8.5 20150623 (red hat 4.8.5-44), 64-bit 2020-12-20 09:38:08.353 est [60437] location: postmastermain, postmaster.c:998 2020-12-20 09:38:08.358 est [60437] log: 00000: listening on ipv4 address "0.0.0.0", port 5432 2020-12-20 09:38:08.358 est [60437] location: streamserverport, pqcomm.c:593 2020-12-20 09:38:08.358 est [60437] log: 00000: listening on ipv6 address "::", port 5432 2020-12-20 09:38:08.358 est [60437] location: streamserverport, pqcomm.c:593 2020-12-20 09:38:08.364 est [60437] log: 00000: listening on unix socket "/tmp/.s.pgsql.5432" 2020-12-20 09:38:08.364 est [60437] location: streamserverport, pqcomm.c:587 2020-12-20 09:38:08.419 est [60437] log: 00000: redirecting log output to logging collector process 2020-12-20 09:38:08.419 est [60437] hint: future log output will appear in directory "/postgresql/pgsql/pg_log". 2020-12-20 09:38:08.419 est [60437] location: syslogger_start, syslogger.c:675 done server started [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ls archive_log backups bin data include lib pg_log pg_rman_backups share [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman init -b /postgresql/pgsql/pg_rman_backups/ info: arclog_path is set to '/postgresql/pgsql/archive_log' info: srvlog_path is set to '/postgresql/pgsql/pg_log' [postgres@node_206 /postgresql/pgsql]$vim pg_rman_backups/pg_rman.ini [postgres@node_206 /postgresql/pgsql]$ll backups/ total 0 [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$vim $pgdata/postgresql.conf [postgres@node_206 /postgresql/pgsql]$pg_ctl restart -m fast waiting for server to shut down.... done server stopped waiting for server to start....2020-12-20 09:38:08.353 est [60437] log: 00000: starting postgresql 12.3 on x86_64-pc-linux-gnu, compiled by gcc (gcc) 4.8.5 20150623 (red hat 4.8.5-44), 64-bit 2020-12-20 09:38:08.353 est [60437] location: postmastermain, postmaster.c:998 2020-12-20 09:38:08.358 est [60437] log: 00000: listening on ipv4 address "0.0.0.0", port 5432 2020-12-20 09:38:08.358 est [60437] location: streamserverport, pqcomm.c:593 2020-12-20 09:38:08.358 est [60437] log: 00000: listening on ipv6 address "::", port 5432 2020-12-20 09:38:08.358 est [60437] location: streamserverport, pqcomm.c:593 2020-12-20 09:38:08.364 est [60437] log: 00000: listening on unix socket "/tmp/.s.pgsql.5432" 2020-12-20 09:38:08.364 est [60437] location: streamserverport, pqcomm.c:587 2020-12-20 09:38:08.419 est [60437] log: 00000: redirecting log output to logging collector process 2020-12-20 09:38:08.419 est [60437] hint: future log output will appear in directory "/postgresql/pgsql/pg_log". 2020-12-20 09:38:08.419 est [60437] location: syslogger_start, syslogger.c:675 done server started [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ls archive_log backups bin data include lib pg_log pg_rman_backups share [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman init -b /postgresql/pgsql/pg_rman_backups/ info: arclog_path is set to '/postgresql/pgsql/archive_log' info: srvlog_path is set to '/postgresql/pgsql/pg_log' [postgres@node_206 /postgresql/pgsql]$vim pg_rman_backups/pg_rman.ini [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$psql -upostgres psql (12.3) type "help" for help. postgres=# \l list of databases name | owner | encoding | collate | ctype | access privileges -----------+----------+----------+-------------+-------------+----------------------- postgres | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | repmgr | repmgr | utf8 | en_us.utf-8 | en_us.utf-8 | template0 | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | =c/postgres + | | | | | postgres=ctc/postgres template1 | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | =c/postgres + | | | | | postgres=ctc/postgres test | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | (5 rows) postgres=# \c test you are now connected to database "test" as user "postgres". test=# create table test_pg_rman (id int, crt_time timestamp default clock_timestamp()); create table test=# insert into test_pg_rman (id) select n from generate_series(1,10000) n; insert 0 10000 test=# \q [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -b /postgresql/pgsql/pg_rman_backups info: copying database files info: copying archived wal files info: backup complete info: please execute 'pg_rman validate' to verify the files are correctly copied. info: start deleting old archived wal files from arclog_path (keep days = 10) info: the threshold timestamp calculated by keep days is "2020-12-10 00:00:00" info: start deleting old backup (keep generations = 3 and keep after = 2020-10-21 00:00:00) info: does not include the backup just taken [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman validate -b /postgresql/pgsql/pg_rman_backups info: validate: "2020-12-20 22:39:35" backup and archive log files by crc info: backup "2020-12-20 22:39:35" is valid [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$cat pg_rman_backups/*ini arclog_path='/postgresql/pgsql/archive_log' srvlog_path='/postgresql/pgsql/pg_log' compress_data = yes keep_arclog_days = 10 keep_data_generations = 3 keep_data_days = 60 keep_srvlog_days = 10 [postgres@node_206 /postgresql/pgsql]$ll /postgresql/pgsql/pg_log/ total 288 -rw-------. 1 postgres postgres 256 nov 15 17:39 postgresql-2020-11-15_043957.log -rw-------. 1 postgres postgres 256 nov 15 18:00 postgresql-2020-11-15_050047.log -rw-------. 1 postgres postgres 256 nov 15 18:08 postgresql-2020-11-15_050800.log -rw-------. 1 postgres postgres 0 nov 16 13:00 postgresql-2020-11-16_000000.log -rw-------. 1 postgres postgres 256 nov 17 07:32 postgresql-2020-11-16_183244.log -rw-------. 1 postgres postgres 256 nov 17 07:33 postgresql-2020-11-16_183333.log -rw-------. 1 postgres postgres 256 nov 17 09:22 postgresql-2020-11-16_202244.log -rw-------. 1 postgres postgres 256 nov 17 09:26 postgresql-2020-11-16_202616.log -rw-------. 1 postgres postgres 256 nov 17 09:32 postgresql-2020-11-16_203210.log -rw-------. 1 postgres postgres 0 nov 17 13:00 postgresql-2020-11-17_000000.log -rw-------. 1 postgres postgres 256 nov 17 16:49 postgresql-2020-11-17_034947.log -rw-------. 1 postgres postgres 448 nov 17 17:06 postgresql-2020-11-17_040642.log -rw-------. 1 postgres postgres 448 nov 17 17:08 postgresql-2020-11-17_040822.log -rw-------. 1 postgres postgres 256 nov 17 17:09 postgresql-2020-11-17_040929.log -rw-------. 1 postgres postgres 256 nov 17 17:11 postgresql-2020-11-17_041114.log -rw-------. 1 postgres postgres 448 nov 17 17:11 postgresql-2020-11-17_041147.log -rw-------. 1 postgres postgres 448 nov 17 17:13 postgresql-2020-11-17_041342.log -rw-------. 1 postgres postgres 256 nov 17 17:15 postgresql-2020-11-17_041506.log -rw-------. 1 postgres postgres 448 nov 17 17:18 postgresql-2020-11-17_041841.log -rw-------. 1 postgres postgres 256 nov 17 17:20 postgresql-2020-11-17_042040.log -rw-------. 1 postgres postgres 744 nov 17 17:23 postgresql-2020-11-17_042334.log -rw-------. 1 postgres postgres 448 nov 17 17:31 postgresql-2020-11-17_043101.log -rw-------. 1 postgres postgres 352 nov 17 17:46 postgresql-2020-11-17_044648.log -rw-------. 1 postgres postgres 352 nov 17 17:47 postgresql-2020-11-17_044749.log -rw-------. 1 postgres postgres 256 nov 17 17:48 postgresql-2020-11-17_044854.log -rw-------. 1 postgres postgres 256 nov 17 18:10 postgresql-2020-11-17_051036.log -rw-------. 1 postgres postgres 256 nov 17 18:12 postgresql-2020-11-17_051236.log -rw-------. 1 postgres postgres 256 nov 17 18:29 postgresql-2020-11-17_052955.log -rw-------. 1 postgres postgres 1384 nov 17 18:32 postgresql-2020-11-17_053216.log -rw-------. 1 postgres postgres 256 nov 17 23:25 postgresql-2020-11-17_102510.log -rw-------. 1 postgres postgres 256 nov 17 23:27 postgresql-2020-11-17_102736.log -rw-------. 1 postgres postgres 256 nov 17 23:32 postgresql-2020-11-17_103209.log -rw-------. 1 postgres postgres 256 nov 17 23:34 postgresql-2020-11-17_103402.log -rw-------. 1 postgres postgres 256 nov 17 23:34 postgresql-2020-11-17_103422.log -rw-------. 1 postgres postgres 256 nov 17 23:36 postgresql-2020-11-17_103641.log -rw-------. 1 postgres postgres 256 nov 17 23:45 postgresql-2020-11-17_104513.log -rw-------. 1 postgres postgres 256 nov 17 23:53 postgresql-2020-11-17_105341.log -rw-------. 1 postgres postgres 448 nov 18 00:00 postgresql-2020-11-17_110030.log -rw-------. 1 postgres postgres 256 nov 18 00:00 postgresql-2020-11-17_110051.log -rw-------. 1 postgres postgres 256 nov 18 00:01 postgresql-2020-11-17_110130.log -rw-------. 1 postgres postgres 256 nov 18 00:08 postgresql-2020-11-17_110826.log -rw-------. 1 postgres postgres 256 nov 18 00:14 postgresql-2020-11-17_111446.log -rw-------. 1 postgres postgres 1136 nov 18 00:15 postgresql-2020-11-17_111504.log -rw-------. 1 postgres postgres 256 nov 18 02:41 postgresql-2020-11-17_134136.log -rw-------. 1 postgres postgres 256 nov 18 02:41 postgresql-2020-11-17_134151.log -rw-------. 1 postgres postgres 256 nov 17 17:28 postgresql-2020-11-17_172801.log -rw-------. 1 postgres postgres 256 nov 17 17:40 postgresql-2020-11-17_174037.log -rw-------. 1 postgres postgres 256 nov 17 17:44 postgresql-2020-11-17_174409.log -rw-------. 1 postgres postgres 560 nov 17 17:50 postgresql-2020-11-17_175020.log -rw-------. 1 postgres postgres 560 nov 17 17:52 postgresql-2020-11-17_175256.log -rw-------. 1 postgres postgres 360 nov 17 17:58 postgresql-2020-11-17_175847.log -rw-------. 1 postgres postgres 256 nov 17 17:59 postgresql-2020-11-17_175928.log -rw-------. 1 postgres postgres 360 nov 17 18:00 postgresql-2020-11-17_180030.log -rw-------. 1 postgres postgres 360 nov 17 18:01 postgresql-2020-11-17_180115.log -rw-------. 1 postgres postgres 256 nov 17 18:04 postgresql-2020-11-17_180404.log -rw-------. 1 postgres postgres 360 nov 17 18:07 postgresql-2020-11-17_180712.log -rw-------. 1 postgres postgres 360 nov 17 18:07 postgresql-2020-11-17_180740.log -rw-------. 1 postgres postgres 360 nov 17 18:11 postgresql-2020-11-17_181126.log -rw-------. 1 postgres postgres 360 nov 17 18:19 postgresql-2020-11-17_181918.log -rw-------. 1 postgres postgres 256 nov 17 18:24 postgresql-2020-11-17_182446.log -rw-------. 1 postgres postgres 256 nov 17 18:25 postgresql-2020-11-17_182540.log -rw-------. 1 postgres postgres 256 nov 17 18:26 postgresql-2020-11-17_182619.log -rw-------. 1 postgres postgres 256 nov 17 18:27 postgresql-2020-11-17_182733.log -rw-------. 1 postgres postgres 256 nov 17 18:27 postgresql-2020-11-17_182743.log -rw-------. 1 postgres postgres 256 nov 17 18:28 postgresql-2020-11-17_182847.log -rw-------. 1 postgres postgres 256 nov 17 18:29 postgresql-2020-11-17_182916.log -rw-------. 1 postgres postgres 256 nov 17 18:30 postgresql-2020-11-17_183028.log -rw-------. 1 postgres postgres 256 nov 17 18:33 postgresql-2020-11-17_183304.log -rw-------. 1 postgres postgres 256 nov 17 18:34 postgresql-2020-11-17_183413.log -rw-------. 1 postgres postgres 256 nov 17 18:34 postgresql-2020-11-17_183450.log -rw-------. 1 postgres postgres 256 nov 17 23:06 postgresql-2020-11-17_230648.log -rw-------. 1 postgres postgres 256 nov 17 23:20 postgresql-2020-11-17_232015.log -rw-------. 1 postgres postgres 256 dec 20 22:37 postgresql-2020-12-20_093747.log -rw-------. 1 postgres postgres 256 dec 20 22:38 postgresql-2020-12-20_093808.log [postgres@node_206 /postgresql/pgsql]$cat pg_rman_backups/*ini arclog_path='/postgresql/pgsql/archive_log' srvlog_path='/postgresql/pgsql/pg_log' compress_data = yes keep_arclog_days = 10 keep_data_generations = 3 keep_data_days = 60 keep_srvlog_days = 10 [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-12-20 22:39:35 2020-12-20 22:39:37 full 5451kb 10 ok [postgres@node_206 /postgresql/pgsql]$psql -d test psql (12.3) type "help" for help. test=# select count(*) from test_pg_rman ; count ------- 10000 (1 row) test=# insert into test_pg_rman (id) select n from generate_series(10001,20000) n; insert 0 10000 test=# \q [postgres@node_206 /postgresql/pgsql]$pg_rman backup -bi -b /postgresql/pgsql/pg_rman_backups info: copying database files info: copying archived wal files info: backup complete info: please execute 'pg_rman validate' to verify the files are correctly copied. info: start deleting old archived wal files from arclog_path (keep days = 10) info: the threshold timestamp calculated by keep days is "2020-12-10 00:00:00" info: start deleting old backup (keep generations = 3 and keep after = 2020-10-21 00:00:00) info: does not include the backup just taken info: backup "2020-12-20 22:39:35" should be kept detail: this is the 1st latest full backup. [postgres@node_206 /postgresql/pgsql]$pg_rman validate -b /postgresql/pgsql/pg_rman_backups info: validate: "2020-12-20 22:41:40" backup and archive log files by crc info: backup "2020-12-20 22:41:40" is valid [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-12-20 22:41:40 2020-12-20 22:41:43 incr 390kb 10 ok 2020-12-20 22:39:35 2020-12-20 22:39:37 full 5451kb 10 ok [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$psql -u test psql: error: could not connect to server: fatal: role "test" does not exist [postgres@node_206 /postgresql/pgsql]$psql -u postgres -d test psql (12.3) type "help" for help. test=# truncate test_pg_rman ; truncate table test=# \q [postgres@node_206 /postgresql/pgsql]$pg_ctl stop waiting for server to shut down.... done server stopped [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:39:35' error: cannot do restore detail: there is no valid full backup which can be used for given recovery condition. [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:41:40' info: the recovery target timeline id is not given info: use timeline id of current database cluster as recovery target: 10 info: calculating timeline branches to be used to recovery target point info: searching latest full backup which can be used as restore start point info: found the full backup can be used as base in recovery: "2020-12-20 22:39:35" info: copying online wal files and server log files info: clearing restore destination info: validate: "2020-12-20 22:39:35" backup and archive log files by size info: backup "2020-12-20 22:39:35" is valid info: restoring database files from the full mode backup "2020-12-20 22:39:35" info: searching incremental backup to be restored info: searching backup which contained archived wal files to be restored info: backup "2020-12-20 22:39:35" is valid info: restoring wal files from backup "2020-12-20 22:39:35" info: backup "2020-12-20 22:41:40" is valid info: restoring wal files from backup "2020-12-20 22:41:40" info: restoring online wal files and server log files info: add recovery related options to postgresql.conf info: generating recovery.signal info: restore complete hint: recovery will start automatically when the postgresql server is started. [postgres@node_206 /postgresql/pgsql]$pg_ctl start waiting for server to start....2020-12-20 09:43:32.516 est [60584] log: 00000: starting postgresql 12.3 on x86_64-pc-linux-gnu, compiled by gcc (gcc) 4.8.5 20150623 (red hat 4.8.5-44), 64-bit 2020-12-20 09:43:32.516 est [60584] location: postmastermain, postmaster.c:998 2020-12-20 09:43:32.518 est [60584] log: 00000: listening on ipv4 address "0.0.0.0", port 5432 2020-12-20 09:43:32.518 est [60584] location: streamserverport, pqcomm.c:593 2020-12-20 09:43:32.519 est [60584] log: 00000: listening on ipv6 address "::", port 5432 2020-12-20 09:43:32.519 est [60584] location: streamserverport, pqcomm.c:593 2020-12-20 09:43:32.520 est [60584] log: 00000: listening on unix socket "/tmp/.s.pgsql.5432" 2020-12-20 09:43:32.520 est [60584] location: streamserverport, pqcomm.c:587 2020-12-20 09:43:32.565 est [60584] log: 00000: redirecting log output to logging collector process 2020-12-20 09:43:32.565 est [60584] hint: future log output will appear in directory "/postgresql/pgsql/pg_log". 2020-12-20 09:43:32.565 est [60584] location: syslogger_start, syslogger.c:675 done server started [postgres@node_206 /postgresql/pgsql]$psql psql (12.3) type "help" for help. postgres=# select * from pg_is_in_recovery(); pg_is_in_recovery ------------------- t (1 row) postgres=# select pg_wal_replay_resume(); pg_wal_replay_resume ---------------------- (1 row) postgres=# select * from pg_is_in_recovery(); pg_is_in_recovery ------------------- f (1 row) postgres=# \q [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-12-20 22:41:40 2020-12-20 22:41:43 incr 390kb 10 ok 2020-12-20 22:39:35 2020-12-20 22:39:37 full 5451kb 10 ok [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_controldata /postgresql/pgsql/data/ pg_control version number: 1201 catalog version number: 201909212 database system identifier: 6895281636782426835 database cluster state: in production pg_control last modified: sun 20 dec 2020 10:43:51 pm cst latest checkpoint location: 0/86000028 latest checkpoint's redo location: 0/86000028 latest checkpoint's redo wal file: 0000000b0000000000000086 latest checkpoint's timelineid: 11 latest checkpoint's prevtimelineid: 10 latest checkpoint's full_page_writes: on latest checkpoint's nextxid: 0:7753 latest checkpoint's nextoid: 25080 latest checkpoint's nextmultixactid: 1 latest checkpoint's nextmultioffset: 0 latest checkpoint's oldestxid: 479 latest checkpoint's oldestxid's db: 1 latest checkpoint's oldestactivexid: 0 latest checkpoint's oldestmultixid: 1 latest checkpoint's oldestmulti's db: 1 latest checkpoint's oldestcommittsxid:0 latest checkpoint's newestcommittsxid:0 time of latest checkpoint: sun 20 dec 2020 10:43:51 pm cst fake lsn counter for unlogged rels: 0/3e8 minimum recovery ending location: 0/0 min recovery ending loc's timeline: 0 backup start location: 0/0 backup end location: 0/0 end-of-backup record required: no wal_level setting: replica wal_log_hints setting: on max_connections setting: 200 max_worker_processes setting: 8 max_wal_senders setting: 10 max_prepared_xacts setting: 0 max_locks_per_xact setting: 64 track_commit_timestamp setting: off maximum data alignment: 8 database block size: 8192 blocks per segment of large relation: 131072 wal block size: 8192 bytes per wal segment: 16777216 maximum length of identifiers: 64 maximum columns in an index: 32 maximum size of a toast chunk: 1996 size of a large-object chunk: 2048 date/time type storage: 64-bit integers float4 argument passing: by value float8 argument passing: by value data page checksum version: 0 mock authentication nonce: 0e803fe626d0bf49403235ba1f4f8a665eb48d4d847cb7863dcad401e65676ca [postgres@node_206 /postgresql/pgsql]$ll data/pg_wal/ total 180268 -rw-------. 1 postgres postgres 42 dec 20 22:43 00000002.history -rw-------. 1 postgres postgres 85 dec 20 22:43 00000003.history -rw-------. 1 postgres postgres 128 dec 20 22:43 00000004.history -rw-------. 1 postgres postgres 171 dec 20 22:43 00000005.history -rw-------. 1 postgres postgres 216 dec 20 22:43 00000006.history -rw-------. 1 postgres postgres 261 dec 20 22:43 00000007.history -rw-------. 1 postgres postgres 261 dec 20 22:43 00000008.history -rw-------. 1 postgres postgres 304 dec 20 22:43 00000009.history -rw-------. 1 postgres postgres 349 dec 20 22:43 0000000a0000000000000085.00000028.backup -rw-------. 1 postgres postgres 259 dec 20 22:43 0000000a.history -rw-------. 1 postgres postgres 16777216 dec 20 22:43 0000000b0000000000000086 -rw-------. 1 postgres postgres 16777216 dec 20 22:43 0000000b0000000000000087 -rw-------. 1 postgres postgres 16777216 dec 20 22:43 0000000b0000000000000088 -rw-------. 1 postgres postgres 16777216 dec 20 22:43 0000000b0000000000000089 -rw-------. 1 postgres postgres 16777216 dec 20 22:43 0000000b000000000000008a -rw-------. 1 postgres postgres 16777216 dec 20 22:43 0000000b000000000000008b -rw-------. 1 postgres postgres 16777216 dec 20 22:43 0000000b000000000000008c -rw-------. 1 postgres postgres 16777216 dec 20 22:43 0000000b000000000000008d -rw-------. 1 postgres postgres 16777216 dec 20 22:43 0000000b000000000000008e -rw-------. 1 postgres postgres 16777216 dec 20 22:43 0000000b000000000000008f -rw-------. 1 postgres postgres 16777216 dec 20 22:43 0000000b0000000000000090 -rw-------. 1 postgres postgres 312 dec 20 22:43 0000000b.history drwx------. 2 postgres postgres 233 dec 20 22:43 archive_status [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$psql psql (12.3) type "help" for help. postgres=# \c test you are now connected to database "test" as user "postgres". test=# select count(*) from test; count ------- 2000 (1 row) test=# select count(*) from test_pg_rman ; count ------- 20000 (1 row) test=# insert into test_pg_rman (id) select n from generate_series(20001,30000) n; insert 0 10000 test=# \q [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-12-20 22:41:40 2020-12-20 22:41:43 incr 390kb 10 ok 2020-12-20 22:39:35 2020-12-20 22:39:37 full 5451kb 10 ok [postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -b /postgresql/pgsql/pg_rman_backups info: copying database files info: copying archived wal files info: backup complete info: please execute 'pg_rman validate' to verify the files are correctly copied. info: start deleting old archived wal files from arclog_path (keep days = 10) info: the threshold timestamp calculated by keep days is "2020-12-10 00:00:00" info: start deleting old backup (keep generations = 3 and keep after = 2020-10-21 00:00:00) info: does not include the backup just taken info: backup "2020-12-20 22:41:40" should be kept detail: this belongs to the 1st latest full backup. info: backup "2020-12-20 22:39:35" should be kept detail: this is the 1st latest full backup. [postgres@node_206 /postgresql/pgsql]$pg_rman validate -b /postgresql/pgsql/pg_rman_backups info: validate: "2020-12-20 22:51:24" backup and archive log files by crc info: backup "2020-12-20 22:51:24" is valid [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-12-20 22:51:24 2020-12-20 22:51:27 full 6184kb 11 ok 2020-12-20 22:41:40 2020-12-20 22:41:43 incr 390kb 10 ok 2020-12-20 22:39:35 2020-12-20 22:39:37 full 5451kb 10 ok [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_ctl stop waiting for server to shut down.... done server stopped [postgres@node_206 /postgresql/pgsql]$ll total 32 drwxr-xr-x. 2 postgres postgres 4096 dec 20 22:51 archive_log drwxrwxr-x. 2 postgres postgres 6 nov 17 15:51 backups drwxr-xr-x. 2 postgres postgres 4096 nov 17 16:43 bin drwx------. 19 postgres postgres 4096 dec 20 22:51 data drwxr-xr-x. 6 postgres postgres 4096 nov 15 16:14 include drwxr-xr-x. 4 postgres postgres 4096 nov 17 06:37 lib drwxr-xr-x. 2 postgres postgres 4096 dec 20 22:43 pg_log drwxrwxr-x. 5 postgres postgres 104 dec 20 22:39 pg_rman_backups drwxr-xr-x. 8 postgres postgres 4096 nov 15 16:14 share [postgres@node_206 /postgresql/pgsql]$mv data data_origin [postgres@node_206 /postgresql/pgsql]$pg_ctl start pg_ctl: directory "/postgresql/pgsql/data" does not exist [postgres@node_206 /postgresql/pgsql]$pg_ctl start pg_ctl: directory "/postgresql/pgsql/data" does not exist [postgres@node_206 /postgresql/pgsql]$mv data_origin/ data [postgres@node_206 /postgresql/pgsql]$pg_ctl start waiting for server to start....2020-12-20 09:52:26.732 est [60723] log: 00000: starting postgresql 12.3 on x86_64-pc-linux-gnu, compiled by gcc (gcc) 4.8.5 20150623 (red hat 4.8.5-44), 64-bit 2020-12-20 09:52:26.732 est [60723] location: postmastermain, postmaster.c:998 2020-12-20 09:52:26.738 est [60723] log: 00000: listening on ipv4 address "0.0.0.0", port 5432 2020-12-20 09:52:26.738 est [60723] location: streamserverport, pqcomm.c:593 2020-12-20 09:52:26.738 est [60723] log: 00000: listening on ipv6 address "::", port 5432 2020-12-20 09:52:26.738 est [60723] location: streamserverport, pqcomm.c:593 2020-12-20 09:52:26.740 est [60723] log: 00000: listening on unix socket "/tmp/.s.pgsql.5432" 2020-12-20 09:52:26.740 est [60723] location: streamserverport, pqcomm.c:587 2020-12-20 09:52:26.791 est [60723] log: 00000: redirecting log output to logging collector process 2020-12-20 09:52:26.791 est [60723] hint: future log output will appear in directory "/postgresql/pgsql/pg_log". 2020-12-20 09:52:26.791 est [60723] location: syslogger_start, syslogger.c:675 done server started [postgres@node_206 /postgresql/pgsql]$psql -u postgres psql (12.3) type "help" for help. postgres=# drop database test; drop database postgres=# \q [postgres@node_206 /postgresql/pgsql]$pg_ctl stop waiting for server to shut down.... done server stopped [postgres@node_206 /postgresql/pgsql]$mv data/ data_origin [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ warning: pg_controldata file "/postgresql/pgsql/data/global/pg_control" does not exist info: the recovery target timeline id is not given info: use timeline id of latest full backup as recovery target: 11 info: calculating timeline branches to be used to recovery target point info: searching latest full backup which can be used as restore start point info: found the full backup can be used as base in recovery: "2020-12-20 22:51:24" info: copying online wal files and server log files info: clearing restore destination info: validate: "2020-12-20 22:51:24" backup and archive log files by size info: backup "2020-12-20 22:51:24" is valid info: restoring database files from the full mode backup "2020-12-20 22:51:24" info: searching incremental backup to be restored info: searching backup which contained archived wal files to be restored info: backup "2020-12-20 22:51:24" is valid info: restoring wal files from backup "2020-12-20 22:51:24" info: restoring online wal files and server log files info: add recovery related options to postgresql.conf info: generating recovery.signal info: restore complete hint: recovery will start automatically when the postgresql server is started. [postgres@node_206 /postgresql/pgsql]$pg_ctl start waiting for server to start....2020-12-20 09:53:09.888 est [60773] log: 00000: starting postgresql 12.3 on x86_64-pc-linux-gnu, compiled by gcc (gcc) 4.8.5 20150623 (red hat 4.8.5-44), 64-bit 2020-12-20 09:53:09.888 est [60773] location: postmastermain, postmaster.c:998 2020-12-20 09:53:09.889 est [60773] log: 00000: listening on ipv4 address "0.0.0.0", port 5432 2020-12-20 09:53:09.889 est [60773] location: streamserverport, pqcomm.c:593 2020-12-20 09:53:09.890 est [60773] log: 00000: listening on ipv6 address "::", port 5432 2020-12-20 09:53:09.890 est [60773] location: streamserverport, pqcomm.c:593 2020-12-20 09:53:09.893 est [60773] log: 00000: listening on unix socket "/tmp/.s.pgsql.5432" 2020-12-20 09:53:09.893 est [60773] location: streamserverport, pqcomm.c:587 2020-12-20 09:53:09.947 est [60773] log: 00000: redirecting log output to logging collector process 2020-12-20 09:53:09.947 est [60773] hint: future log output will appear in directory "/postgresql/pgsql/pg_log". 2020-12-20 09:53:09.947 est [60773] location: syslogger_start, syslogger.c:675 done server started [postgres@node_206 /postgresql/pgsql]$psql psql (12.3) type "help" for help. postgres=# \c test you are now connected to database "test" as user "postgres". test=# \dt list of relations schema | name | type | owner --------+--------------+-------+---------- public | test | table | postgres public | test_pg_rman | table | postgres (2 rows) test=# select count(*) from test_pg_rman; count ------- 30000 (1 row) test=# select count(*) from test; count ------- 2000 (1 row) test=# test=# select * from pg_is_in_recovery(); pg_is_in_recovery ------------------- t (1 row) test=# select pg_wal_replay_resume(); pg_wal_replay_resume ---------------------- (1 row) test=# select * from pg_is_in_recovery(); pg_is_in_recovery ------------------- f (1 row) test=# \q [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ ===================================================================== starttime endtime mode size tli status ===================================================================== 2020-12-20 22:51:24 2020-12-20 22:51:27 full 6184kb 11 ok 2020-12-20 22:41:40 2020-12-20 22:41:43 incr 390kb 10 ok 2020-12-20 22:39:35 2020-12-20 22:39:37 full 5451kb 10 ok [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:39:35' error: postgresql server is running hint: please stop postgresql server before executing restore. [postgres@node_206 /postgresql/pgsql]$pg_ctl stop waiting for server to shut down.... done server stopped [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:39:35' error: cannot do restore detail: there is no valid full backup which can be used for given recovery condition. [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:39:36' error: cannot do restore detail: there is no valid full backup which can be used for given recovery condition. [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:39:34' error: cannot do restore detail: there is no valid full backup which can be used for given recovery condition. [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:39:20' error: cannot do restore detail: there is no valid full backup which can be used for given recovery condition. [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:39:24 > ^c [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:39:24' error: cannot do restore detail: there is no valid full backup which can be used for given recovery condition. [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:39:24' -p error: cannot do restore detail: there is no valid full backup which can be used for given recovery condition. [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:39:24' -p-v pg_rman: invalid option -- '-' error: option is not specified hint: try "pg_rman --help" for more information. [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:39:24' -pv ======================================== restore start error: cannot do restore detail: there is no valid full backup which can be used for given recovery condition. [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:39:24' -pv --debug ======================================== restore start debug: the current timeline id of database cluster is 12 error: cannot do restore detail: there is no valid full backup which can be used for given recovery condition. [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ details error: arguments are invalid. near "details" [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ detail ====================================================================================================================== starttime endtime mode data arclog srvlog total compressed curtli parenttli status ====================================================================================================================== 2020-12-20 22:51:24 2020-12-20 22:51:27 full 45mb 117mb ---- 6184kb true 11 10 ok 2020-12-20 22:41:40 2020-12-20 22:41:43 incr 1237kb 33mb ---- 390kb true 10 0 ok 2020-12-20 22:39:35 2020-12-20 22:39:37 full 44mb 33mb ---- 5451kb true 10 0 ok [postgres@node_206 /postgresql/pgsql]$ls archive_log backups bin data data_origin include lib pg_log pg_rman_backups share [postgres@node_206 /postgresql/pgsql]$pg_controldata /postgresql/pgsql/data/ pg_control version number: 1201 catalog version number: 201909212 database system identifier: 6895281636782426835 database cluster state: shut down pg_control last modified: sun 20 dec 2020 10:54:14 pm cst latest checkpoint location: 0/89000028 latest checkpoint's redo location: 0/89000028 latest checkpoint's redo wal file: 0000000c0000000000000089 latest checkpoint's timelineid: 12 latest checkpoint's prevtimelineid: 12 latest checkpoint's full_page_writes: on latest checkpoint's nextxid: 0:7755 latest checkpoint's nextoid: 25080 latest checkpoint's nextmultixactid: 1 latest checkpoint's nextmultioffset: 0 latest checkpoint's oldestxid: 479 latest checkpoint's oldestxid's db: 1 latest checkpoint's oldestactivexid: 0 latest checkpoint's oldestmultixid: 1 latest checkpoint's oldestmulti's db: 1 latest checkpoint's oldestcommittsxid:0 latest checkpoint's newestcommittsxid:0 time of latest checkpoint: sun 20 dec 2020 10:54:14 pm cst fake lsn counter for unlogged rels: 0/3e8 minimum recovery ending location: 0/0 min recovery ending loc's timeline: 0 backup start location: 0/0 backup end location: 0/0 end-of-backup record required: no wal_level setting: replica wal_log_hints setting: on max_connections setting: 200 max_worker_processes setting: 8 max_wal_senders setting: 10 max_prepared_xacts setting: 0 max_locks_per_xact setting: 64 track_commit_timestamp setting: off maximum data alignment: 8 database block size: 8192 blocks per segment of large relation: 131072 wal block size: 8192 bytes per wal segment: 16777216 maximum length of identifiers: 64 maximum columns in an index: 32 maximum size of a toast chunk: 1996 size of a large-object chunk: 2048 date/time type storage: 64-bit integers float4 argument passing: by value float8 argument passing: by value data page checksum version: 0 mock authentication nonce: 0e803fe626d0bf49403235ba1f4f8a665eb48d4d847cb7863dcad401e65676ca [postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -b /postgresql/pgsql/pg_rman_backups error: could not connect to database postgres: could not connect to server: no such file or directory is the server running locally and accepting connections on unix domain socket "/tmp/.s.pgsql.5432"? [postgres@node_206 /postgresql/pgsql]$pg_ctl start waiting for server to start....2020-12-20 09:56:02.612 est [60839] log: 00000: starting postgresql 12.3 on x86_64-pc-linux-gnu, compiled by gcc (gcc) 4.8.5 20150623 (red hat 4.8.5-44), 64-bit 2020-12-20 09:56:02.612 est [60839] location: postmastermain, postmaster.c:998 2020-12-20 09:56:02.613 est [60839] log: 00000: listening on ipv4 address "0.0.0.0", port 5432 2020-12-20 09:56:02.613 est [60839] location: streamserverport, pqcomm.c:593 2020-12-20 09:56:02.613 est [60839] log: 00000: listening on ipv6 address "::", port 5432 2020-12-20 09:56:02.613 est [60839] location: streamserverport, pqcomm.c:593 2020-12-20 09:56:02.615 est [60839] log: 00000: listening on unix socket "/tmp/.s.pgsql.5432" 2020-12-20 09:56:02.615 est [60839] location: streamserverport, pqcomm.c:587 2020-12-20 09:56:02.664 est [60839] log: 00000: redirecting log output to logging collector process 2020-12-20 09:56:02.664 est [60839] hint: future log output will appear in directory "/postgresql/pgsql/pg_log". 2020-12-20 09:56:02.664 est [60839] location: syslogger_start, syslogger.c:675 done server started [postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -b /postgresql/pgsql/pg_rman_backups info: copying database files info: copying archived wal files info: backup complete info: please execute 'pg_rman validate' to verify the files are correctly copied. info: start deleting old archived wal files from arclog_path (keep days = 10) info: the threshold timestamp calculated by keep days is "2020-12-10 00:00:00" info: start deleting old backup (keep generations = 3 and keep after = 2020-10-21 00:00:00) info: does not include the backup just taken warning: backup "2020-12-20 22:55:57" is not taken into account detail: this is not a valid backup. info: backup "2020-12-20 22:51:24" should be kept detail: this is the 1st latest full backup. info: backup "2020-12-20 22:41:40" should be kept detail: this belongs to the 2nd latest full backup. info: backup "2020-12-20 22:39:35" should be kept detail: this is the 2nd latest full backup. [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/data/ --recovery-target-time='2020-11-18 00:10:49' -a /postgresql/pgsql/archive_log/ -s /postgresql/pgsql/pg_log/ error: could not open file "/postgresql/pgsql/data//pg_rman.ini": no such file or directory [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ detail ====================================================================================================================== starttime endtime mode data arclog srvlog total compressed curtli parenttli status ====================================================================================================================== 2020-12-20 22:56:05 2020-12-20 22:56:09 full 45mb 201mb ---- 6251kb true 12 11 done 2020-12-20 22:55:57 2020-12-20 22:55:57 full ---- ---- ---- 0b true 0 0 error 2020-12-20 22:51:24 2020-12-20 22:51:27 full 45mb 117mb ---- 6184kb true 11 10 ok 2020-12-20 22:41:40 2020-12-20 22:41:43 incr 1237kb 33mb ---- 390kb true 10 0 ok 2020-12-20 22:39:35 2020-12-20 22:39:37 full 44mb 33mb ---- 5451kb true 10 0 ok [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_ctl start pg_ctl: another server might be running; trying to start server anyway waiting for server to start....2020-12-20 10:01:14.923 est [60948] fatal: f0001: lock file "postmaster.pid" already exists 2020-12-20 10:01:14.923 est [60948] hint: is another postmaster (pid 60839) running in data directory "/postgresql/pgsql/data"? 2020-12-20 10:01:14.923 est [60948] location: createlockfile, miscinit.c:1034 stopped waiting pg_ctl: could not start server examine the log output. [postgres@node_206 /postgresql/pgsql]$psql -u postgres -d test psql (12.3) type "help" for help. test=# create table test2 (like test); create table test=# \d test2 table "public.test2" column | type | collation | nullable | default ----------+-----------------------------+-----------+----------+--------- id | integer | | | crt_time | timestamp without time zone | | | test=# insert into test2 (id ) select n from generate_series(1,1000000) n; insert 0 1000000 test=# \q [postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=incremental -b /postgresql/pgsql/pg_rman_backups info: copying database files error: cannot take an incremental backup detail: there is no validated full backup with current timeline. hint: please take a full backup and validate it before doing an incremental backup. or use with --full-backup-on-error command line option. [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -b /postgresql/pgsql/pg_rman_backups info: copying database files info: copying archived wal files info: backup complete info: please execute 'pg_rman validate' to verify the files are correctly copied. info: start deleting old archived wal files from arclog_path (keep days = 10) info: the threshold timestamp calculated by keep days is "2020-12-10 00:00:00" info: start deleting old backup (keep generations = 3 and keep after = 2020-10-21 00:00:00) info: does not include the backup just taken warning: backup "2020-12-20 23:01:58" is not taken into account detail: this is not a valid backup. warning: backup "2020-12-20 22:56:05" is not taken into account detail: this is not a valid backup. warning: backup "2020-12-20 22:55:57" is not taken into account detail: this is not a valid backup. info: backup "2020-12-20 22:51:24" should be kept detail: this is the 1st latest full backup. info: backup "2020-12-20 22:41:40" should be kept detail: this belongs to the 2nd latest full backup. info: backup "2020-12-20 22:39:35" should be kept detail: this is the 2nd latest full backup. [postgres@node_206 /postgresql/pgsql]$pg_rman validate -b /postgresql/pgsql/pg_rman_backups info: validate: "2020-12-20 22:56:05" backup and archive log files by crc info: backup "2020-12-20 22:56:05" is valid info: validate: "2020-12-20 23:02:07" backup and archive log files by crc info: backup "2020-12-20 23:02:07" is valid [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ detail ====================================================================================================================== starttime endtime mode data arclog srvlog total compressed curtli parenttli status ====================================================================================================================== 2020-12-20 23:02:07 2020-12-20 23:02:13 full 82mb 301mb ---- 23mb true 12 11 ok 2020-12-20 23:01:58 2020-12-20 23:01:58 incr 0b ---- ---- 0b true 12 11 error 2020-12-20 22:56:05 2020-12-20 22:56:09 full 45mb 201mb ---- 6251kb true 12 11 ok 2020-12-20 22:55:57 2020-12-20 22:55:57 full ---- ---- ---- 0b true 0 0 error 2020-12-20 22:51:24 2020-12-20 22:51:27 full 45mb 117mb ---- 6184kb true 11 10 ok 2020-12-20 22:41:40 2020-12-20 22:41:43 incr 1237kb 33mb ---- 390kb true 10 0 ok 2020-12-20 22:39:35 2020-12-20 22:39:37 full 44mb 33mb ---- 5451kb true 10 0 ok [postgres@node_206 /postgresql/pgsql]$pg_ctl stop waiting for server to shut down.... done server stopped [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:39:24' -pv --debug [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:39:24' -pv [postgres@node_206 /postgresql/pgsql]$pg_rman restore -b /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:56:05' info: the recovery target timeline id is not given info: use timeline id of current database cluster as recovery target: 12 info: calculating timeline branches to be used to recovery target point info: searching latest full backup which can be used as restore start point info: found the full backup can be used as base in recovery: "2020-12-20 22:51:24" info: copying online wal files and server log files info: clearing restore destination info: validate: "2020-12-20 22:51:24" backup and archive log files by size info: backup "2020-12-20 22:51:24" is valid info: restoring database files from the full mode backup "2020-12-20 22:51:24" info: searching incremental backup to be restored info: searching backup which contained archived wal files to be restored info: backup "2020-12-20 22:51:24" is valid info: restoring wal files from backup "2020-12-20 22:51:24" info: backup "2020-12-20 22:56:05" is valid info: restoring wal files from backup "2020-12-20 22:56:05" info: backup "2020-12-20 23:02:07" is valid info: restoring wal files from backup "2020-12-20 23:02:07" info: restoring online wal files and server log files info: add recovery related options to postgresql.conf info: generating recovery.signal info: restore complete hint: recovery will start automatically when the postgresql server is started. [postgres@node_206 /postgresql/pgsql]$pg_ctl start waiting for server to start....2020-12-20 10:03:39.933 est [61032] log: 00000: starting postgresql 12.3 on x86_64-pc-linux-gnu, compiled by gcc (gcc) 4.8.5 20150623 (red hat 4.8.5-44), 64-bit 2020-12-20 10:03:39.933 est [61032] location: postmastermain, postmaster.c:998 2020-12-20 10:03:39.935 est [61032] log: 00000: listening on ipv4 address "0.0.0.0", port 5432 2020-12-20 10:03:39.935 est [61032] location: streamserverport, pqcomm.c:593 2020-12-20 10:03:39.936 est [61032] log: 00000: listening on ipv6 address "::", port 5432 2020-12-20 10:03:39.936 est [61032] location: streamserverport, pqcomm.c:593 2020-12-20 10:03:39.941 est [61032] log: 00000: listening on unix socket "/tmp/.s.pgsql.5432" 2020-12-20 10:03:39.941 est [61032] location: streamserverport, pqcomm.c:587 2020-12-20 10:03:39.982 est [61032] log: 00000: redirecting log output to logging collector process 2020-12-20 10:03:39.982 est [61032] hint: future log output will appear in directory "/postgresql/pgsql/pg_log". 2020-12-20 10:03:39.982 est [61032] location: syslogger_start, syslogger.c:675 done server started [postgres@node_206 /postgresql/pgsql]$psql -d test psql (12.3) type "help" for help. test=# \dt list of relations schema | name | type | owner --------+--------------+-------+---------- public | test | table | postgres public | test_pg_rman | table | postgres (2 rows) test=# select pg_wal_replay_resume(); pg_wal_replay_resume ---------------------- (1 row) test=# test=# select * from pg_is_in_recovery(); pg_is_in_recovery ------------------- f (1 row) test=# \q [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ detail ====================================================================================================================== starttime endtime mode data arclog srvlog total compressed curtli parenttli status ====================================================================================================================== 2020-12-20 23:02:07 2020-12-20 23:02:13 full 82mb 301mb ---- 23mb true 12 11 ok 2020-12-20 23:01:58 2020-12-20 23:01:58 incr 0b ---- ---- 0b true 12 11 error 2020-12-20 22:56:05 2020-12-20 22:56:09 full 45mb 201mb ---- 6251kb true 12 11 ok 2020-12-20 22:55:57 2020-12-20 22:55:57 full ---- ---- ---- 0b true 0 0 error 2020-12-20 22:51:24 2020-12-20 22:51:27 full 45mb 117mb ---- 6184kb true 11 10 ok 2020-12-20 22:41:40 2020-12-20 22:41:43 incr 1237kb 33mb ---- 390kb true 10 0 ok 2020-12-20 22:39:35 2020-12-20 22:39:37 full 44mb 33mb ---- 5451kb true 10 0 ok [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_controldata /postgresql/pgsql/data/ pg_control version number: 1201 catalog version number: 201909212 database system identifier: 6895281636782426835 database cluster state: in production pg_control last modified: sun 20 dec 2020 11:03:50 pm cst latest checkpoint location: 0/8b000028 latest checkpoint's redo location: 0/8b000028 latest checkpoint's redo wal file: 0000000d000000000000008b latest checkpoint's timelineid: 13 latest checkpoint's prevtimelineid: 12 latest checkpoint's full_page_writes: on latest checkpoint's nextxid: 0:7755 latest checkpoint's nextoid: 25080 latest checkpoint's nextmultixactid: 1 latest checkpoint's nextmultioffset: 0 latest checkpoint's oldestxid: 479 latest checkpoint's oldestxid's db: 1 latest checkpoint's oldestactivexid: 0 latest checkpoint's oldestmultixid: 1 latest checkpoint's oldestmulti's db: 1 latest checkpoint's oldestcommittsxid:0 latest checkpoint's newestcommittsxid:0 time of latest checkpoint: sun 20 dec 2020 11:03:50 pm cst fake lsn counter for unlogged rels: 0/3e8 minimum recovery ending location: 0/0 min recovery ending loc's timeline: 0 backup start location: 0/0 backup end location: 0/0 end-of-backup record required: no wal_level setting: replica wal_log_hints setting: on max_connections setting: 200 max_worker_processes setting: 8 max_wal_senders setting: 10 max_prepared_xacts setting: 0 max_locks_per_xact setting: 64 track_commit_timestamp setting: off maximum data alignment: 8 database block size: 8192 blocks per segment of large relation: 131072 wal block size: 8192 bytes per wal segment: 16777216 maximum length of identifiers: 64 maximum columns in an index: 32 maximum size of a toast chunk: 1996 size of a large-object chunk: 2048 date/time type storage: 64-bit integers float4 argument passing: by value float8 argument passing: by value data page checksum version: 0 mock authentication nonce: 0e803fe626d0bf49403235ba1f4f8a665eb48d4d847cb7863dcad401e65676ca [postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -b /postgresql/pgsql/pg_rman_backups info: copying database files info: copying archived wal files info: backup complete info: please execute 'pg_rman validate' to verify the files are correctly copied. info: start deleting old archived wal files from arclog_path (keep days = 10) info: the threshold timestamp calculated by keep days is "2020-12-10 00:00:00" info: start deleting old backup (keep generations = 3 and keep after = 2020-10-21 00:00:00) info: does not include the backup just taken info: backup "2020-12-20 23:02:07" should be kept detail: this is the 1st latest full backup. warning: backup "2020-12-20 23:01:58" is not taken into account detail: this is not a valid backup. info: backup "2020-12-20 22:56:05" should be kept detail: this is the 2nd latest full backup. warning: backup "2020-12-20 22:55:57" is not taken into account detail: this is not a valid backup. info: backup "2020-12-20 22:51:24" should be kept detail: this is the 3rd latest full backup. info: backup "2020-12-20 22:41:40" should be kept detail: this is taken after "2020-10-21 00:00:00". info: backup "2020-12-20 22:39:35" should be kept detail: this is taken after "2020-10-21 00:00:00". [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ detail ====================================================================================================================== starttime endtime mode data arclog srvlog total compressed curtli parenttli status ====================================================================================================================== 2020-12-20 23:04:19 2020-12-20 23:04:25 full 45mb 352mb ---- 19mb true 13 12 done 2020-12-20 23:02:07 2020-12-20 23:02:13 full 82mb 301mb ---- 23mb true 12 11 ok 2020-12-20 23:01:58 2020-12-20 23:01:58 incr 0b ---- ---- 0b true 12 11 error 2020-12-20 22:56:05 2020-12-20 22:56:09 full 45mb 201mb ---- 6251kb true 12 11 ok 2020-12-20 22:55:57 2020-12-20 22:55:57 full ---- ---- ---- 0b true 0 0 error 2020-12-20 22:51:24 2020-12-20 22:51:27 full 45mb 117mb ---- 6184kb true 11 10 ok 2020-12-20 22:41:40 2020-12-20 22:41:43 incr 1237kb 33mb ---- 390kb true 10 0 ok 2020-12-20 22:39:35 2020-12-20 22:39:37 full 44mb 33mb ---- 5451kb true 10 0 ok [postgres@node_206 /postgresql/pgsql]$pg_rman validate -b /postgresql/pgsql/pg_rman_backups info: validate: "2020-12-20 23:04:19" backup and archive log files by crc info: backup "2020-12-20 23:04:19" is valid [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ detail ====================================================================================================================== starttime endtime mode data arclog srvlog total compressed curtli parenttli status ====================================================================================================================== 2020-12-20 23:04:19 2020-12-20 23:04:25 full 45mb 352mb ---- 19mb true 13 12 ok 2020-12-20 23:02:07 2020-12-20 23:02:13 full 82mb 301mb ---- 23mb true 12 11 ok 2020-12-20 23:01:58 2020-12-20 23:01:58 incr 0b ---- ---- 0b true 12 11 error 2020-12-20 22:56:05 2020-12-20 22:56:09 full 45mb 201mb ---- 6251kb true 12 11 ok 2020-12-20 22:55:57 2020-12-20 22:55:57 full ---- ---- ---- 0b true 0 0 error 2020-12-20 22:51:24 2020-12-20 22:51:27 full 45mb 117mb ---- 6184kb true 11 10 ok 2020-12-20 22:41:40 2020-12-20 22:41:43 incr 1237kb 33mb ---- 390kb true 10 0 ok 2020-12-20 22:39:35 2020-12-20 22:39:37 full 44mb 33mb ---- 5451kb true 10 0 ok [postgres@node_206 /postgresql/pgsql]$psql -d test psql (12.3) type "help" for help. test=# \dt list of relations schema | name | type | owner --------+--------------+-------+---------- public | test | table | postgres public | test_pg_rman | table | postgres (2 rows) test=# create table test2(like test); create table test=# insert into test2 select * from test; insert 0 2000 test=# \q [postgres@node_206 /postgresql/pgsql]$pg_rman backup -bi -b /postgresql/pgsql/pg_rman_backups info: copying database files info: copying archived wal files info: backup complete info: please execute 'pg_rman validate' to verify the files are correctly copied. info: start deleting old archived wal files from arclog_path (keep days = 10) info: the threshold timestamp calculated by keep days is "2020-12-10 00:00:00" info: start deleting old backup (keep generations = 3 and keep after = 2020-10-21 00:00:00) info: does not include the backup just taken info: backup "2020-12-20 23:04:19" should be kept detail: this is the 1st latest full backup. info: backup "2020-12-20 23:02:07" should be kept detail: this is the 2nd latest full backup. warning: backup "2020-12-20 23:01:58" is not taken into account detail: this is not a valid backup. info: backup "2020-12-20 22:56:05" should be kept detail: this is the 3rd latest full backup. warning: backup "2020-12-20 22:55:57" is not taken int account detail: this is not valid backup. info: backup "2020-12-20 22:51:24" should be kept detail: this is taken after "2020-10-21 00:00:00". info: backup "2020-12-20 22:41:40" should be kept detail: this is taken after "2020-10-21 00:00:00". info: backup "2020-12-20 22:39:35" should be kept detail: this is taken after "2020-10-21 00:00:00". [postgres@node_206 /postgresql/pgsql]$pg_rman validate -b /postgresql/pgsql/pg_rman_backups info: validate: "2020-12-20 23:06:51" backup and archive log files by crc info: backup "2020-12-20 23:06:51" is valid [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ detail ====================================================================================================================== starttime endtime mode data arclog srvlog total compressed curtli parenttli status ====================================================================================================================== 2020-12-20 23:06:51 2020-12-20 23:06:53 incr 2465kb 33mb ---- 112kb true 13 12 ok 2020-12-20 23:04:19 2020-12-20 23:04:25 full 45mb 352mb ---- 19mb true 13 12 ok 2020-12-20 23:02:07 2020-12-20 23:02:13 full 82mb 301mb ---- 23mb true 12 11 ok 2020-12-20 23:01:58 2020-12-20 23:01:58 incr 0b ---- ---- 0b true 12 11 error 2020-12-20 22:56:05 2020-12-20 22:56:09 full 45mb 201mb ---- 6251kb true 12 11 ok 2020-12-20 22:55:57 2020-12-20 22:55:57 full ---- ---- ---- 0b true 0 0 error 2020-12-20 22:51:24 2020-12-20 22:51:27 full 45mb 117mb ---- 6184kb true 11 10 ok 2020-12-20 22:41:40 2020-12-20 22:41:43 incr 1237kb 33mb ---- 390kb true 10 0 ok 2020-12-20 22:39:35 2020-12-20 22:39:37 full 44mb 33mb ---- 5451kb true 10 0 ok [postgres@node_206 /postgresql/pgsql]$psql -d test psql (12.3) type "help" for help. test=# create table test34(like test); create table test=# create table test3(like test); create table test=# insert into test3 select * from test; insert 0 2000 test=# \q [postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -b /postgresql/pgsql/pg_rman_backups info: copying database files info: copying archived wal files info: backup complete info: please execute 'pg_rman validate' to verify the files are correctly copied. info: start deleting old archived wal files from arclog_path (keep days = 10) info: the threshold timestamp calculated by keep days is "2020-12-10 00:00:00" info: start deleting old backup (keep generations = 3 and keep after = 2020-10-21 00:00:00) info: does not include the backup just taken info: backup "2020-12-20 23:06:51" should be kept detail: this belongs to the 1st latest full backup. info: backup "2020-12-20 23:04:19" should be kept detail: this is the 1st latest full backup. info: backup "2020-12-20 23:02:07" should be kept detail: this is the 2nd latest full backup. warning: backup "2020-12-20 23:01:58" is not taken into account detail: this is not a valid backup. info: backup "2020-12-20 22:56:05" should be kept detail: this is the 3rd latest full backup. warning: backup "2020-12-20 22:55:57" is not taken int account detail: this is not valid backup. info: backup "2020-12-20 22:51:24" should be kept detail: this is taken after "2020-10-21 00:00:00". info: backup "2020-12-20 22:41:40" should be kept detail: this is taken after "2020-10-21 00:00:00". info: backup "2020-12-20 22:39:35" should be kept detail: this is taken after "2020-10-21 00:00:00". [postgres@node_206 /postgresql/pgsql]$pg_rman validate -b /postgresql/pgsql/pg_rman_backups info: validate: "2020-12-20 23:08:23" backup and archive log files by crc info: backup "2020-12-20 23:08:23" is valid [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ detail ====================================================================================================================== starttime endtime mode data arclog srvlog total compressed curtli parenttli status ====================================================================================================================== 2020-12-20 23:08:23 2020-12-20 23:08:25 full 46mb 33mb ---- 5495kb true 13 12 ok 2020-12-20 23:06:51 2020-12-20 23:06:53 incr 2465kb 33mb ---- 112kb true 13 12 ok 2020-12-20 23:04:19 2020-12-20 23:04:25 full 45mb 352mb ---- 19mb true 13 12 ok 2020-12-20 23:02:07 2020-12-20 23:02:13 full 82mb 301mb ---- 23mb true 12 11 ok 2020-12-20 23:01:58 2020-12-20 23:01:58 incr 0b ---- ---- 0b true 12 11 error 2020-12-20 22:56:05 2020-12-20 22:56:09 full 45mb 201mb ---- 6251kb true 12 11 ok 2020-12-20 22:55:57 2020-12-20 22:55:57 full ---- ---- ---- 0b true 0 0 error 2020-12-20 22:51:24 2020-12-20 22:51:27 full 45mb 117mb ---- 6184kb true 11 10 ok 2020-12-20 22:41:40 2020-12-20 22:41:43 incr 1237kb 33mb ---- 390kb true 10 0 ok 2020-12-20 22:39:35 2020-12-20 22:39:37 full 44mb 33mb ---- 5451kb true 10 0 ok [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$psql -d test psql (12.3) type "help" for help. test=# creat table test4(like test); error: syntax error at or near "creat" line 1: creat table test4(like test); ^ test=# create table test4(like test); create table test=# insert into test4 select * from test; insert 0 2000 test=# test=# \q [postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -b /postgresql/pgsql/pg_rman_backups info: copying database files info: copying archived wal files info: backup complete info: please execute 'pg_rman validate' to verify the files are correctly copied. info: start deleting old archived wal files from arclog_path (keep days = 10) info: the threshold timestamp calculated by keep days is "2020-12-10 00:00:00" info: start deleting old backup (keep generations = 3 and keep after = 2020-10-21 00:00:00) info: does not include the backup just taken info: backup "2020-12-20 23:08:23" should be kept detail: this is the 1st latest full backup. info: backup "2020-12-20 23:06:51" should be kept detail: this belongs to the 2nd latest full backup. info: backup "2020-12-20 23:04:19" should be kept detail: this is the 2nd latest full backup. info: backup "2020-12-20 23:02:07" should be kept detail: this is the 3rd latest full backup. warning: backup "2020-12-20 23:01:58" is not taken int account detail: this is not valid backup. info: backup "2020-12-20 22:56:05" should be kept detail: this is taken after "2020-10-21 00:00:00". warning: backup "2020-12-20 22:55:57" is not taken int account detail: this is not valid backup. info: backup "2020-12-20 22:51:24" should be kept detail: this is taken after "2020-10-21 00:00:00". info: backup "2020-12-20 22:41:40" should be kept detail: this is taken after "2020-10-21 00:00:00". info: backup "2020-12-20 22:39:35" should be kept detail: this is taken after "2020-10-21 00:00:00". [postgres@node_206 /postgresql/pgsql]$pg_rman validate -b /postgresql/pgsql/pg_rman_backups info: validate: "2020-12-20 23:09:48" backup and archive log files by crc info: backup "2020-12-20 23:09:48" is valid [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ detail ====================================================================================================================== starttime endtime mode data arclog srvlog total compressed curtli parenttli status ====================================================================================================================== 2020-12-20 23:09:48 2020-12-20 23:09:50 full 46mb 33mb ---- 5507kb true 13 12 ok 2020-12-20 23:08:23 2020-12-20 23:08:25 full 46mb 33mb ---- 5495kb true 13 12 ok 2020-12-20 23:06:51 2020-12-20 23:06:53 incr 2465kb 33mb ---- 112kb true 13 12 ok 2020-12-20 23:04:19 2020-12-20 23:04:25 full 45mb 352mb ---- 19mb true 13 12 ok 2020-12-20 23:02:07 2020-12-20 23:02:13 full 82mb 301mb ---- 23mb true 12 11 ok 2020-12-20 23:01:58 2020-12-20 23:01:58 incr 0b ---- ---- 0b true 12 11 error 2020-12-20 22:56:05 2020-12-20 22:56:09 full 45mb 201mb ---- 6251kb true 12 11 ok 2020-12-20 22:55:57 2020-12-20 22:55:57 full ---- ---- ---- 0b true 0 0 error 2020-12-20 22:51:24 2020-12-20 22:51:27 full 45mb 117mb ---- 6184kb true 11 10 ok 2020-12-20 22:41:40 2020-12-20 22:41:43 incr 1237kb 33mb ---- 390kb true 10 0 ok 2020-12-20 22:39:35 2020-12-20 22:39:37 full 44mb 33mb ---- 5451kb true 10 0 ok [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$psql -d test psql (12.3) type "help" for help. test=# create table test5(like test); create table test=# insert into test5 select * from test; insert 0 2000 test=# \q [postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -b /postgresql/pgsql/pg_rman_backups info: copying database files info: copying archived wal files info: backup complete info: please execute 'pg_rman validate' to verify the files are correctly copied. info: start deleting old archived wal files from arclog_path (keep days = 10) info: the threshold timestamp calculated by keep days is "2020-12-10 00:00:00" info: start deleting old backup (keep generations = 3 and keep after = 2020-10-21 00:00:00) info: does not include the backup just taken info: backup "2020-12-20 23:09:48" should be kept detail: this is the 1st latest full backup. info: backup "2020-12-20 23:08:23" should be kept detail: this is the 2nd latest full backup. info: backup "2020-12-20 23:06:51" should be kept detail: this belongs to the 3rd latest full backup. info: backup "2020-12-20 23:04:19" should be kept detail: this is the 3rd latest full backup. info: backup "2020-12-20 23:02:07" should be kept detail: this is taken after "2020-10-21 00:00:00". warning: backup "2020-12-20 23:01:58" is not taken int account detail: this is not valid backup. info: backup "2020-12-20 22:56:05" should be kept detail: this is taken after "2020-10-21 00:00:00". warning: backup "2020-12-20 22:55:57" is not taken int account detail: this is not valid backup. info: backup "2020-12-20 22:51:24" should be kept detail: this is taken after "2020-10-21 00:00:00". info: backup "2020-12-20 22:41:40" should be kept detail: this is taken after "2020-10-21 00:00:00". info: backup "2020-12-20 22:39:35" should be kept detail: this is taken after "2020-10-21 00:00:00". [postgres@node_206 /postgresql/pgsql]$pg_rman validate -b /postgresql/pgsql/pg_rman_backups info: validate: "2020-12-20 23:10:12" backup and archive log files by crc info: backup "2020-12-20 23:10:12" is valid [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ detail ====================================================================================================================== starttime endtime mode data arclog srvlog total compressed curtli parenttli status ====================================================================================================================== 2020-12-20 23:10:12 2020-12-20 23:10:14 full 46mb 33mb ---- 5520kb true 13 12 ok 2020-12-20 23:09:48 2020-12-20 23:09:50 full 46mb 33mb ---- 5507kb true 13 12 ok 2020-12-20 23:08:23 2020-12-20 23:08:25 full 46mb 33mb ---- 5495kb true 13 12 ok 2020-12-20 23:06:51 2020-12-20 23:06:53 incr 2465kb 33mb ---- 112kb true 13 12 ok 2020-12-20 23:04:19 2020-12-20 23:04:25 full 45mb 352mb ---- 19mb true 13 12 ok 2020-12-20 23:02:07 2020-12-20 23:02:13 full 82mb 301mb ---- 23mb true 12 11 ok 2020-12-20 23:01:58 2020-12-20 23:01:58 incr 0b ---- ---- 0b true 12 11 error 2020-12-20 22:56:05 2020-12-20 22:56:09 full 45mb 201mb ---- 6251kb true 12 11 ok 2020-12-20 22:55:57 2020-12-20 22:55:57 full ---- ---- ---- 0b true 0 0 error 2020-12-20 22:51:24 2020-12-20 22:51:27 full 45mb 117mb ---- 6184kb true 11 10 ok 2020-12-20 22:41:40 2020-12-20 22:41:43 incr 1237kb 33mb ---- 390kb true 10 0 ok 2020-12-20 22:39:35 2020-12-20 22:39:37 full 44mb 33mb ---- 5451kb true 10 0 ok [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$psql -d test psql (12.3) type "help" for help. test=# create table test5(like test); error: relation "test5" already exists test=# create table test6(like test); create table test=# insert into test6 select * from test; insert 0 2000 test=# \q [postgres@node_206 /postgresql/pgsql]$pg_rman backup -bi -b /postgresql/pgsql/pg_rman_backups info: copying database files info: copying archived wal files info: backup complete info: please execute 'pg_rman validate' to verify the files are correctly copied. info: start deleting old archived wal files from arclog_path (keep days = 10) info: the threshold timestamp calculated by keep days is "2020-12-10 00:00:00" info: start deleting old backup (keep generations = 3 and keep after = 2020-10-21 00:00:00) info: does not include the backup just taken info: backup "2020-12-20 23:10:12" should be kept detail: this is the 1st latest full backup. info: backup "2020-12-20 23:09:48" should be kept detail: this is the 2nd latest full backup. info: backup "2020-12-20 23:08:23" should be kept detail: this is the 3rd latest full backup. info: backup "2020-12-20 23:06:51" should be kept detail: this is taken after "2020-10-21 00:00:00". info: backup "2020-12-20 23:04:19" should be kept detail: this is taken after "2020-10-21 00:00:00". info: backup "2020-12-20 23:02:07" should be kept detail: this is taken after "2020-10-21 00:00:00". warning: backup "2020-12-20 23:01:58" is not taken int account detail: this is not valid backup. info: backup "2020-12-20 22:56:05" should be kept detail: this is taken after "2020-10-21 00:00:00". warning: backup "2020-12-20 22:55:57" is not taken int account detail: this is not valid backup. info: backup "2020-12-20 22:51:24" should be kept detail: this is taken after "2020-10-21 00:00:00". info: backup "2020-12-20 22:41:40" should be kept detail: this is taken after "2020-10-21 00:00:00". info: backup "2020-12-20 22:39:35" should be kept detail: this is taken after "2020-10-21 00:00:00". [postgres@node_206 /postgresql/pgsql]$pg_rman validate -b /postgresql/pgsql/pg_rman_backups info: validate: "2020-12-20 23:12:23" backup and archive log files by crc info: backup "2020-12-20 23:12:23" is valid [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ detail ====================================================================================================================== starttime endtime mode data arclog srvlog total compressed curtli parenttli status ====================================================================================================================== 2020-12-20 23:12:23 2020-12-20 23:12:25 incr 2621kb 33mb ---- 140kb true 13 12 ok 2020-12-20 23:10:12 2020-12-20 23:10:14 full 46mb 33mb ---- 5520kb true 13 12 ok 2020-12-20 23:09:48 2020-12-20 23:09:50 full 46mb 33mb ---- 5507kb true 13 12 ok 2020-12-20 23:08:23 2020-12-20 23:08:25 full 46mb 33mb ---- 5495kb true 13 12 ok 2020-12-20 23:06:51 2020-12-20 23:06:53 incr 2465kb 33mb ---- 112kb true 13 12 ok 2020-12-20 23:04:19 2020-12-20 23:04:25 full 45mb 352mb ---- 19mb true 13 12 ok 2020-12-20 23:02:07 2020-12-20 23:02:13 full 82mb 301mb ---- 23mb true 12 11 ok 2020-12-20 23:01:58 2020-12-20 23:01:58 incr 0b ---- ---- 0b true 12 11 error 2020-12-20 22:56:05 2020-12-20 22:56:09 full 45mb 201mb ---- 6251kb true 12 11 ok 2020-12-20 22:55:57 2020-12-20 22:55:57 full ---- ---- ---- 0b true 0 0 error 2020-12-20 22:51:24 2020-12-20 22:51:27 full 45mb 117mb ---- 6184kb true 11 10 ok 2020-12-20 22:41:40 2020-12-20 22:41:43 incr 1237kb 33mb ---- 390kb true 10 0 ok 2020-12-20 22:39:35 2020-12-20 22:39:37 full 44mb 33mb ---- 5451kb true 10 0 ok [postgres@node_206 /postgresql/pgsql]$ [postgres@node_206 /postgresql/pgsql]$psql -d test psql (12.3) type "help" for help. test=# create table test7(like test); create table test=# insert into test7 select * from test; insert 0 2000 test=# \q [postgres@node_206 /postgresql/pgsql]$pg_rman backup -bf -b /postgresql/pgsql/pg_rman_backups info: copying database files info: copying archived wal files info: backup complete info: please execute 'pg_rman validate' to verify the files are correctly copied. info: start deleting old archived wal files from arclog_path (keep days = 10) info: the threshold timestamp calculated by keep days is "2020-12-10 00:00:00" info: start deleting old backup (keep generations = 3 and keep after = 2020-10-21 00:00:00) info: does not include the backup just taken info: backup "2020-12-20 23:12:23" should be kept detail: this belongs to the 1st latest full backup. info: backup "2020-12-20 23:10:12" should be kept detail: this is the 1st latest full backup. info: backup "2020-12-20 23:09:48" should be kept detail: this is the 2nd latest full backup. info: backup "2020-12-20 23:08:23" should be kept detail: this is the 3rd latest full backup. info: backup "2020-12-20 23:06:51" should be kept detail: this is taken after "2020-10-21 00:00:00". info: backup "2020-12-20 23:04:19" should be kept detail: this is taken after "2020-10-21 00:00:00". info: backup "2020-12-20 23:02:07" should be kept detail: this is taken after "2020-10-21 00:00:00". warning: backup "2020-12-20 23:01:58" is not taken int account detail: this is not valid backup. info: backup "2020-12-20 22:56:05" should be kept detail: this is taken after "2020-10-21 00:00:00". warning: backup "2020-12-20 22:55:57" is not taken int account detail: this is not valid backup. info: backup "2020-12-20 22:51:24" should be kept detail: this is taken after "2020-10-21 00:00:00". info: backup "2020-12-20 22:41:40" should be kept detail: this is taken after "2020-10-21 00:00:00". info: backup "2020-12-20 22:39:35" should be kept detail: this is taken after "2020-10-21 00:00:00". [postgres@node_206 /postgresql/pgsql]$pg_rman validate -b /postgresql/pgsql/pg_rman_backups info: validate: "2020-12-20 23:12:47" backup and archive log files by crc info: backup "2020-12-20 23:12:47" is valid [postgres@node_206 /postgresql/pgsql]$pg_rman show -b /postgresql/pgsql/pg_rman_backups/ detail ====================================================================================================================== starttime endtime mode data arclog srvlog total compressed curtli parenttli status ====================================================================================================================== 2020-12-20 23:12:47 2020-12-20 23:12:50 full 46mb 33mb ---- 5546kb true 13 12 ok 2020-12-20 23:12:23 2020-12-20 23:12:25 incr 2621kb 33mb ---- 140kb true 13 12 ok 2020-12-20 23:10:12 2020-12-20 23:10:14 full 46mb 33mb ---- 5520kb true 13 12 ok 2020-12-20 23:09:48 2020-12-20 23:09:50 full 46mb 33mb ---- 5507kb true 13 12 ok 2020-12-20 23:08:23 2020-12-20 23:08:25 full 46mb 33mb ---- 5495kb true 13 12 ok 2020-12-20 23:06:51 2020-12-20 23:06:53 incr 2465kb 33mb ---- 112kb true 13 12 ok 2020-12-20 23:04:19 2020-12-20 23:04:25 full 45mb 352mb ---- 19mb true 13 12 ok
总结
在 基于时间点恢复时, 如果之前做过恢复,那么此时db与之前的备份已经不在同一时间线上。恢复默认只沿着基础备份建立时时间线恢复而不会切换到新的时间线,如果不做处理,恢复结果将和前面的完整恢复一模一样,恢复不出新插入的数据, 所以建议在恢复之后,可以接着做一个全库的备份
恢复之后, 数据库可能处于 read-only状态,此时可以用超户执行select pg_wal_replay_resume(); 或者在启动数据库实例前在postgresql.conf中添加recovery_target_action=‘promote’
pg_rman init 之后会生产 pg_rman.ini文件, 此时可以编辑该文件并添加备份策略,
我们以一个例子来说明:总共保留两周的数据,即14天的数据,每周进行一次全备,每周一和周三的2:00做一次增量备份,每天进行一次归档备份,这样我们需要对pg_rman.init中做如下配置:
keep_data_generations=2 keep_data_days=14 keep_arclog_days=15 keep_srvlog_days=180
因为我们需要两个全备份,所以keep_data_generations=2
两周的数据所以keep_data_days=14,而可以把wal日志多保留一天,所以keep_arclog_days=15
至少保留1000个wal文件,每个wal为16m,所以大约16g,占用空间不算大。
keep_srvlog_days=180,通常程序日志不太,所以保留180天的日志,即3个月。
建议备份时添加参数 -c -z
建议恢复时添加参数–hard-copy
如果没有指定这个参数,pg_rman实际上是把在归档目录中建一个软链接 指向恢复中要用到的wal日志文件。如果指定了这个参数,则执行真的拷贝。
过程中遇到的问题
linux 系统时间与 pg 中的时间不一致
解决方法:
rm -f /etc/localtime ln -sf /usr/share/zoneinfo/asia/shanghai /etc/localtime
以上为个人经验,希望能给大家一个参考,也希望大家多多支持www.887551.com。如有错误或未考虑完全的地方,望不吝赐教。