This repository has been archived by the owner on May 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 577
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from xcompass/db-backup
Enable database backup through Wal-E
- Loading branch information
Showing
6 changed files
with
93 additions
and
1 deletion.
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 |
---|---|---|
@@ -1,3 +1,18 @@ | ||
FROM postgres:9.4 | ||
|
||
|
||
RUN apt-get update \ | ||
&& apt-get install -y python-dev lzop pv daemontools curl build-essential \ | ||
&& curl --silent --show-error --retry 5 https://bootstrap.pypa.io/get-pip.py | python \ | ||
&& pip install wal-e \ | ||
&& apt-get remove -y build-essential python-dev \ | ||
&& apt-get autoremove -y \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
ADD make_db.sh /docker-entrypoint-initdb.d/ | ||
ADD setup-wale.sh /docker-entrypoint-initdb.d/ | ||
COPY docker-entrypoint1.sh / | ||
|
||
ENTRYPOINT ["/docker-entrypoint1.sh"] | ||
|
||
CMD ["postgres"] |
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,29 @@ | ||
#!/bin/bash | ||
|
||
if [ "${1:0:1}" = '-' ]; then | ||
set -- postgres "$@" | ||
fi | ||
|
||
if [ "$1" = 'postgres' ]; then | ||
VARS=(AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY WALE_S3_PREFIX AWS_REGION) | ||
|
||
for v in ${VARS[@]}; do | ||
if [ "${!v}" = "" ]; then | ||
echo "$v is required for Wal-E but not set. Skipping Wal-E setup." | ||
. /docker-entrypoint.sh | ||
exit | ||
fi | ||
done | ||
|
||
umask u=rwx,g=rx,o= | ||
mkdir -p /etc/wal-e.d/env | ||
|
||
for v in ${VARS[@]}; do | ||
echo "${!v}" > /etc/wal-e.d/env/$v | ||
done | ||
chown -R root:postgres /etc/wal-e.d | ||
|
||
. /docker-entrypoint.sh | ||
fi | ||
|
||
exec "$@" |
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,11 @@ | ||
#!/bin/bash | ||
|
||
# wal-e specific | ||
echo "wal_level = archive" >> /var/lib/postgresql/data/postgresql.conf | ||
echo "archive_mode = on" >> /var/lib/postgresql/data/postgresql.conf | ||
echo "archive_command = 'envdir /etc/wal-e.d/env /usr/local/bin/wal-e wal-push %p'" >> /var/lib/postgresql/data/postgresql.conf | ||
echo "archive_timeout = 60" >> /var/lib/postgresql/data/postgresql.conf | ||
|
||
# no cron in the image, use systemd timer on host instead | ||
#su - postgres -c "crontab -l | { cat; echo \"0 3 * * * /usr/bin/envdir /etc/wal-e.d/env /usr/local/bin/wal-e backup-push /var/lib/postgresql/data\"; } | crontab -" | ||
#su - postgres -c "crontab -l | { cat; echo \"0 4 * * * /usr/bin/envdir /etc/wal-e.d/env /usr/local/bin/wal-e delete --confirm retain 7\"; } | crontab -" |
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