PostgreSQL Tools
barman-wal-restore-reverse.py
Script to restore WAL files in reverse manner. It may be used together with barman-wal-restore.
Script barman-wal-restore downloads multiple WAL files from Barman server to local file system and then returns them one by one to PostgreSQL Server. It's a good point to request multiple files by time to speed up recovery process but still not good enough when you have a lot of WAL files to download.
To help improve this situation barman-wal-restore-reverse.py was made. It can be used to download WAL files from Barman in reverse order, beginning from last available down to WAL processed by barman-wal-restore script.
Example of use:
- Switch to postgresql user
sudo su - postgres
- Find default spool directory of barman-wal-restore script
barman-wal-restore --help
...
--spool-dir SPOOL_DIR Specifies spool directory for WAL files. Defaults to '/var/tmp/walrestore'.
...
- Go to the barman and find most recent backup
barman list-backup myserver
myserver 20220516T125248 - Mon May 16 15:14:17 2022 - Size: 6.4 TiB - WAL Size: 1.6 TiB
- Switch to tmux, because it can take some time
tmux
- Run the script, but do not stop it. Because after restart it will download only new logs after last stop.
barman-wal-restore-reverse.py \
-d /var/tmp/walrestore \
-U barman \
barman.server myserver 20220516T125248