postgres=# show archive_mode;
archive_mode
--------------
off
(1 row)
postgres=# show archive_command;;
archive_command
-----------------
(disabled)
(1 row)
--Let’s create directories for backups and archives (login as root USER):
mkdir -p /Archive/Location
mkdir /backups
chown postgres:postgres -R Archive
chown postgres:postgres /backups
--check the folder permission
[root@p1 /]# ls -lrt
drwxr-xr-x 2 postgres postgres 4096 Apr 10 07:54 backups
drwxr-xr-x 3 postgres postgres 4096 Apr 10 07:54 Archive
--switch to postgres user and modify postgresql.conf. Making the cluster into Archive-log mode requires RESTART.
[root@p1 /]# su postgres
cd $PGDATA
echo 'max_wal_senders=1' >> postgresql.conf
echo 'wal_level=hot_standby' >> postgresql.conf
echo 'archive_mode=on' >> postgresql.conf
echo "archive_command='cp %p /Archive/Location/%f'" >> postgresql.conf
--Restart the server and check the server whether running or not
bash-3.2$ pg_ctl restart -D $PGDATA
waiting for server to shut down.... done
server stopped
server starting
bash-3.2$ 2017-04-10 08:12:07 EDT LOG: redirecting log output to logging collector process
2017-04-10 08:12:07 EDT HINT: Future log output will appear in directory "pg_log".
bash-3.2$ pg_ctl status -D $PGDATA
pg_ctl: server is running (PID: 9825)
/opt/PostgreSQL/9.3/bin/postgres "-D" "/opt/PostgreSQL/9.3/data"
--After the server start check the archive whether properly enable or not using psql terminal.
postgres=# show archive_mode;
archive_mode
--------------
on
(1 row)
postgres=# show archive_command;
archive_command
----------------------------
cp %p /Archive/Location/%f
(1 row)
postgres=# show wal_level;
wal_level
-------------
hot_standby
(1 row)