Commit 7fb29249 authored by kaiyou's avatar kaiyou

improve the db checkpoint scripts

parent a70f5b27
......@@ -3,11 +3,10 @@
PROJECTDIR=$1
BASEDIR=${2:-.}
SERVICE=${3:-db}
BACKUP=$(date +%s)
cd $PROJECTDIR
docker-compose stop $SERVICE
rm $BASEDIR/wal/*
tar -zcf $BASEDIR/wal/$BACKUP.tar.gz $BASEDIR/db
tar -zcf $BASEDIR/wal/$(date +%s).tar.gz $BASEDIR/db
docker-compose up -d $SERVICE
ls -lah $BASEDIR/wal
\ No newline at end of file
......@@ -4,10 +4,10 @@ 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 {} \;
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 {} \;
ls -lah $BASEDIR/wal
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment