Backup per pg_start_backup

Ich schaue mir gerade unser Backup verfahren an und bin dabei auf eine Frage gestoßen, die ich mir bisher nicht beantworten konnte. Unser Backup sieht so aus:

  • Per Skript pg_start_backup ausführen
  • Tarball erstellen von /var/lib/postgresql/8.4/main
  • pg_stop_backup ausführen

Zusätzlich gibt es ein Skript, welches die WAL Archives wegsichert. Dieses ist in der postgresql.conf als ‘archive_command’ konfiguriert


Die Frage ist nun: Ist es notwendig, nach dem Backup noch das pg_xlog wegzusichern?
Ich denke nein, da nach Ausführung von pg_stop_backup ein WAL Archive erstellt wird, welches u.a. die Änderungen enthalten müsste, die während des Datenbankbackups aufgetreten sind.

In der Doku finde ich dazu folgende Erklärung:
Quelle: PostgreSQL: Documentation: 9.1: Continuous Archiving and Point-in-Time Recovery (PITR)

4.) Again connect to the database as a superuser, and issue the command:

SELECT pg_stop_backup();

This terminates the backup mode and performs an automatic switch to the next WAL segment. The reason for the switch is to arrange for the last WAL segment file written during the backup interval to be ready to archive.

5.) Once the WAL segment files active during the backup are archived, you are done. The file identified by pg_stop_backup’s result is the last segment that is required to form a complete set of backup files. If archive_mode is enabled, pg_stop_backup does not return until the last segment has been archived. Archiving of these files happens automatically since you have already configured archive_command. In most cases this happens quickly, but you are advised to monitor your archive system to ensure there are no delays. If the archive process has fallen behind because of failures of the archive command, it will keep retrying until the archive succeeds and the backup is complete. If you wish to place a time limit on the execution of pg_stop_backup, set an appropriate statement_timeout value.

Ich verstehe das so, dass nach Ausführung von pg_stop_backup ein WAL Archive erstellt wird und damit das Backup komplett ist. Sehe ich das richtig?

Danke für die Hilfe! :slight_smile:

Nein, wenn archive_command korrekt funktioniert.