Postgresql pg_basebackup from slave didnt save WAL’s

backuppg-basebackuppostgresql

Is it possible to shoot a backup with the pg_basebackup utility from the slave server (where of streaming replication with the help of this utility pg_basebackup)?

I have a hot_standby server (streaming replication with pg_basebackup), and periodically run pg_basebackup from slave, but when I open my backup (base.tar.gz) I can't find any WAL files.

Do I have to set up archive_command on master (or slave, idk)?

Best Answer

You might want to try to set up max_wal_senders on your replica, and use --xlog-method=stream instead of --xlog-method=fetch, which would let the basebackup grab the individual WAL records as they are shipped, rather than trying to grab the WAL segments at the end of the basebackup. If you have to use --xlog-method=fetch, then you should set wal_keep_segments high enough to let you take a reasonable basebackup. checkpoint_segments x2 should be reasonable as a starting point.

As a reference, the documentation for the 9.3 version of pg_basebackup is here.

I highly recommend that you test out the backup by restoring it on another server, and running a few tests against it to make sure it comes up in a consistent state, and has a reasonable snapshot of the data that you wanted backed up.

One additional note, if you set up an archive_command under 9.3, and a restore_command in your recovery.conf, your streaming replica will be able to recover itself and continue if network conditions cause streaming replication to lag. An example and discussion of this problem and a solution is talked about here: http://evol-monkey.blogspot.com/2014/09/offsite-replication-problems-and-how-to.html

I hope this helps. =)