Barman
Sissejuhatus
Barman on postgresi varundamise vahend, kus postgresql server saadab pidevalt enda muudatused wal-idena barmani serverisse ning annab seeläbi point-in-time recovery võimekuse.
- Postgres-server 192.168.0.4
- Barman-server 192.168.0.5
Paigaldus Debianis
# apt-get install barman barman-cli
Postgresql server ja barman server peavad suutma mõlemad logida ssh võtmetega üksteise käsureale. Ehk siis barman kasutaja peab saama logida postgres kasutajaga postgres sererisse ja postgres serer omakorda barman kasutajaga barmani serverisse.
Postgresql serveris
# sudo -u postgres ssh-keygen -b 2048 -t rsa -N "" -C "postgres@server-a"
Barman serveris
# sudo -u barman ssh-keygen -b 2048 -t rsa -N "" -C "barman@server-b"
Seadistus
Avame barmani serveris /etc/barman.conf
[barman] barman_home = /srv/barman barman_user = barman log_file = /var/log/barman/barman.log compression = gzip reuse_backup = link backup_method = rsync archiver = on [main-server] description = "Main DB Server" ssh_command = ssh postgres@192.168.0.4 backup_options = exclusive_backup parallel_jobs = 1 conninfo = host=192.168.0.4 user=postgres password=parool last_backup_maximum_age = 33 DAYS minimum_redundancy = 1 retention_policy = RECOVERY WINDOW OF 1 MONTHS
Postgres serveris lisame käsud rsyncida walide barmani saatmise, postgresql.conf
archive_mode = on archive_command = ‘rsync -a %p barman@192.168.0.5:/srv/barman/main-server/incoming/%f`
/var/data/barman/main-server/incoming/%f
Kasutamine
Tekitame main backupi
# barman backup postgres-server
Vaatamiseks
# barman list-backup postges-server
Barman võimaldab ka point-in-time taastamist otse serverisse, kus võetakse aluseks üks backupidest ning täiendatakse seda arhiveeritud wal-idega
# barman recover --target-time "2020-03-04 06:42:34.139167+02:00" --remote-ssh-command "ssh postgres@192.168.0.4" main-server 20200304T010401 /var/data/pgdata