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

PROJECTDIR=$1
USER=$2
BASEDIR=${3:-.}
SERVICE=${4:-db}

cd $PROJECTDIR
rm -rf $(find $BASEDIR/wal -mindepth 1 -type d)
kaiyou's avatar
kaiyou committed
10 11 12
docker-compose exec $SERVICE pg_basebackup -D /wal/$(date +%s) -F t -z -P -U $USER
current=$(ls $BASEDIR/wal | grep 'backup$' |  tail -n 1)
find $BASEDIR/wal -type f ! -newer $current ! -name $current -exec rm {} \;
kaiyou's avatar
kaiyou committed
13
ls -lah $BASEDIR/wal