#The directories are created and owned by postgres. postgres@srv1:~$ sudo mkdir -p /RA/arhive postgres@srv1:~$ sudo mkdir -p /RA/basebackup postgres@srv1:~$ sudo chown -R postgres:postgres /RA/ # In postgresql necessary settings are made. alter system set wal_level = replica ; alter system set archive_mode = on ; alter system set archive_command = ‘test ! -f /RA/archive/%f && cp %p / RA/archive/%f’ # postgresql is restarted. /pg/home/13.6/bin/pg_ctl -o ‘--config-file=/pg/data/13.6/postgresql.conf’ -D /pg/data/13.6/ -l pg.log restart # wal file is switched. select pg_switch_wal(); # The archived wal files is listed. postgres@srv1:~$ ls -1 /RA/archive/ 00000001000000000000002C
It is recommended that the “/RA” (Recovery Area) directory be on a different disk than
the operating system and database.
wal_level determines the contents of wal files. This must be at least replica (default
value) for archiving. In addition to replica, it also has logical option, which contains the
necessary information for logical standby.
archive_command is required to test where to copy/send the wal files so that it
does not overwrite the wal files.
%f, filename
%p directory path location
An example of rsync for archive_command;archive_command=‘rsync -av -z %p postgres@srv2:/mnt/RA/arc/%f’