pgsql_checkpoint.sh 352 Bytes
Newer Older
kaiyou's avatar
kaiyou committed
1 2 3 4 5 6 7 8 9 10 11 12 13
#!/bin/sh

PROJECTDIR=$1
USER=$2
BASEDIR=${3:-.}
SERVICE=${4:-db}
BACKUP=$(date +%s)

cd $PROJECTDIR
rm -rf $(find $BASEDIR/wal -mindepth 1 -type d)
docker-compose exec $SERVICE pg_basebackup -D /wal/$BACKUP -l $BACKUP -F t -z -P -U $USER
find $BASEDIR/wal -type f ! -newer $BASEDIR/wal/*.$BACKUP ! -name "*.$BACKUP" -exec rm {} \;
ls -lah $BASEDIR/wal