PostgreSQL open archiving

Modify postgresql.conf

archive_mode =on
%p = path of file to archive
%f = file name only

archive_command ='cp %p /u01/pgsql/archive/pg_%f'

Restart postgresql

pg_ctl  stop

pg_ctl start 

View Archive

[postgres@redis01 archive]$ ls -lrt
total 32772
-rw------- 1 postgres postgres 16777216 Sep 22 18:49 pg_000000010000000000000001
-rw------- 1 postgres postgres 16777216 Sep 22 18:50 pg_000000010000000000000002
-rw------- 1 postgres postgres 329 Sep 22 18:50 pg_000000010000000000000002.00000060.backup
[postgres@redis01 archive]$ pwd
/u01/pgsql/archive

command using logical operators

1. Command && Command 2 1 1 command will execute successfully execute the command 2
2. Command 1 Command 2 || 1 command will execute the command fails 2

Generates a daily archive directory
archive_command = 'DIR = / u01 / pgsql / archive / `date +% F`; sudo test -d $ DIR && sudo mkdir $ DIR;! Sudo test -f $ DIR /% f && sudo cp! % p $ DIR /% f '

Guess you like

Origin www.cnblogs.com/omsql/p/11568700.html
Recommended