Skip to content

Commit

Permalink
fix(rootfs): always perform an initial backup
Browse files Browse the repository at this point in the history
When you complete a recovery of the database for the first time, a new log timeline is started with
an ID of 2. When you restore again (timeline of 3), the timeline used when the last backup occurred
will be replayed. Because of this, if you restored the database and did not perform a backup, all
data committed after that successful recovery will be lost because only WAL logs from the first
timeline (the timeline that the database was last backed up) will be restored.

In order to fix this, after completing a database recovery we create a fresh backup
in order to establish a new recovery baseline. That way we can now replay from
timeline 2.
  • Loading branch information
Matthew Fisher committed Jun 2, 2016
1 parent f502600 commit db4cd9d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions rootfs/docker-entrypoint-initdb.d/003_restore_from_backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ EOF
-o "-c listen_addresses=''" \
-t 1200 \
-w start
else
echo "No backups found. Performing an initial backup..."
gosu postgres envdir "$WALE_ENVDIR" wal-e backup-push "$PGDATA"
fi

echo "Performing an initial backup..."
gosu postgres envdir "$WALE_ENVDIR" wal-e backup-push "$PGDATA"

# ensure $PGDATA has the right permissions
chown -R postgres:postgres "$PGDATA"
chmod 0700 "$PGDATA"

0 comments on commit db4cd9d

Please sign in to comment.