Last active
May 20, 2024 08:50
-
-
Save sharshenov/ea63446f65cb7034eda1 to your computer and use it in GitHub Desktop.
Making PostgreSQL backup from standby server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. Pause replication | |
sudo -u postgres psql -c 'SELECT pg_xlog_replay_pause();' | |
# 2. Perform backup | |
sudo -u postgres pg_dump -Fc DBNAME > /path/to/backup | |
#3. Resume replication | |
sudo -u postgres psql -c 'SELECT pg_xlog_replay_resume();' | |
#Keep in mind that running above commands will cause recovery lag on the slave, which might be quite large, depending on you database size. Also, take into account the space WAL segments will take, as they will not be replayed on slave during the pause. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment