• Как правильно делать Hot Backups?

    Melkij
    @Melkij
    PostgreSQL DBA
    Что по этому поводу думает мануал:
    www.postgresql.org/docs/current/static/continuous-...
    Some file system backup tools emit warnings or errors if the files they are trying to copy change while the copy proceeds. When taking a base backup of an active database, this situation is normal and not an error. However, you need to ensure that you can distinguish complaints of this sort from real errors. For example, some versions of rsync return a separate exit code for «vanished source files», and you can write a driver script to accept this exit code as a non-error case. Also, some versions of GNU tar return an error code indistinguishable from a fatal error if a file was truncated while tar was copying it. Fortunately, GNU tar versions 1.16 and later exit with 1 if a file was changed during the backup, and 2 for other errors. With GNU tar version 1.23 and later, you can use the warning options --warning=no-file-changed --warning=no-file-removed to hide the related warning messages.



    Т.е. wal-логи нужны, но на их изменения в процессе работы бекапа внимания можно не обращать. Почитайте в мане rsync'а, может ли он игнорировать модификацию файлов.

    Update:
    За прошедшие года с момента этого ответа я успешно переквалифицировался в postgresql DBA. И могу сказать, что корректен ответ vyegorov. Используйте штатный pg_basebackup с указанием --xlog (для 9.1 + внимание на предупреждение в мануале) или --xlog-method=stream для более новых.

    А вот что-либо "чинить" через pg_resetxlog настоятельно не рекомендую. В итоге вы получите непонятно что вместо согласованного состояния базы. Так как именно по xlog база приходит в согласованное транзакциионное состояние при старте.
    Ответ написан
    1 комментарий