Fix #15, WAL in archive mode when backup is off
WAL logs in archive mode will consume a lot more spaces and not useful when backup is off. This fix add ability to switch WAL logs mode based on the backup switch.
This commit is contained in:
parent
ba31a0da79
commit
530e8f0194
@ -1,5 +1,17 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# if wal backup is not enabled, use minimal wal logging to reduce disk space
|
||||||
|
: ${WAL_LEVEL:=minimal}
|
||||||
|
: ${ARCHIVE_MODE:=off}
|
||||||
|
# PGDATA is defined in upstream postgres dockerfile
|
||||||
|
|
||||||
|
function update_conf () {
|
||||||
|
if [ -f $PGDATA/postgresql.conf ]; then
|
||||||
|
sed -i "s/wal_level =.*$/wal_level = $WAL_LEVEL/g" $PGDATA/postgresql.conf
|
||||||
|
sed -i "s/archive_mode =.*$/archive_mode = $ARCHIVE_MODE/g" $PGDATA/postgresql.conf
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if [ "${1:0:1}" = '-' ]; then
|
if [ "${1:0:1}" = '-' ]; then
|
||||||
set -- postgres "$@"
|
set -- postgres "$@"
|
||||||
fi
|
fi
|
||||||
@ -10,6 +22,7 @@ if [ "$1" = 'postgres' ]; then
|
|||||||
for v in ${VARS[@]}; do
|
for v in ${VARS[@]}; do
|
||||||
if [ "${!v}" = "" ]; then
|
if [ "${!v}" = "" ]; then
|
||||||
echo "$v is required for Wal-E but not set. Skipping Wal-E setup."
|
echo "$v is required for Wal-E but not set. Skipping Wal-E setup."
|
||||||
|
update_conf
|
||||||
. /docker-entrypoint.sh
|
. /docker-entrypoint.sh
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
@ -23,7 +36,9 @@ if [ "$1" = 'postgres' ]; then
|
|||||||
done
|
done
|
||||||
chown -R root:postgres /etc/wal-e.d
|
chown -R root:postgres /etc/wal-e.d
|
||||||
|
|
||||||
|
WAL_LEVEL=archive
|
||||||
|
ARCHIVE_MODE=on
|
||||||
|
|
||||||
|
update_conf
|
||||||
. /docker-entrypoint.sh
|
. /docker-entrypoint.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec "$@"
|
|
||||||
|
Reference in New Issue
Block a user