PostgreSQL + barman = бэкап

Некоторые дополнения к инструкции barman

postgresql.conf

Установить archive_timeout в небольшое значение (в секундах), это уменьшит отставание копии от оригинала, если изменений в базе немного.

archive_timeout=60

archive_timeout (integer)

The archive_command is only invoked for completed WAL segments. Hence, if your server generates little WAL traffic (or has slack periods where it does so), there could be a long delay between the completion of a transaction and its safe recording in archive storage. To limit how old unarchived data can be, you can set archive_timeout to force the server to switch to a new WAL segment file periodically. When this parameter is greater than zero, the server will switch to a new segment file whenever this many seconds have elapsed since the last segment file switch, and there has been any database activity, including a single checkpoint. (Increasing checkpoint_timeout will reduce unnecessary checkpoints on an idle system.) Note that archived files that are closed early due to a forced switch are still the same length as completely full files. Therefore, it is unwise to use a very short archive_timeout — it will bloat your archive storage. archive_timeout settings of a minute or so are usually reasonable. This parameter can only be set in the postgresql.conf file or on the server command line.

Перенос архива barman на другой сервер

rsync -avzH  --delete --delete-after barman@barman1:/barman_home/main/* /var/lib/barman/main/

Версия 1.4 научилась наследовать неизменившиеся файлы от предыдущего полного бэкапа ( reuse_backup = link ), поэтому rsync нужно вызывать с опцией -H для сохранения жёстких ссылок

Восстановление

barman recover --remote-ssh-command "ssh postgres@pg-local"  main 20150101T010191 /var/lib/postgresql/9.x/main

Leave a Reply