-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(rootfs): refactor database init process
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, 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 from 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. Other fixes that thie refactor includes: - database attempting to start halfway through recovery - /bin/is_running identifying the database as running during recovery - cleaning up database boot script
- Loading branch information
Matthew Fisher
committed
Jul 25, 2016
1 parent
b66069b
commit b7814ba
Showing
6 changed files
with
25 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
until psql -l -t >/dev/null 2>&1; do sleep 1; done | ||
|
||
while true; do | ||
if [[ ! -f "$PGDATA/recovery.conf" ]] ; then | ||
# Push a fresh backup so we have a new recovery baseline | ||
echo "Performing an initial backup..." | ||
envdir "$WALE_ENVDIR" wal-e backup-push "$PGDATA" | ||
echo "Backup has been completed." | ||
break | ||
fi | ||
sleep 1 | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ | |
set -e | ||
|
||
# check if database is running | ||
gosu postgres pg_ctl status | ||
gosu postgres psql -l -t >/dev/null 2>&1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Create a fresh backup as a starting point | ||
gosu postgres backup-initial & | ||
|
||
# Run periodic backups in the background | ||
gosu postgres backup & |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters