Commit ea957e95 authored by kaiyou's avatar kaiyou

Add a postgres basebackup script

parent 878d67e5
......@@ -3,10 +3,11 @@
PROJECTDIR=$1
BASEDIR=${2:-.}
SERVICE=${3:-db}
BACKUP=$(date +%s)
cd $PROJECTDIR
docker-compose stop $SERVICE
rm $BASEDIR/wal/*
tar -zcf $BASEDIR/wal/$(date +%s).tar.gz $BASEDIR/db
tar -zcf $BASEDIR/wal/$BACKUP.tar.gz $BASEDIR/db
docker-compose up -d $SERVICE
ls -lah $BASEDIR/wal
\ No newline at end of file
#!/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
\ 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