1
1
Fork 0

added postgresql backup script

This commit is contained in:
David Starzengruber 2011-02-17 13:59:53 +01:00
parent d49b956fff
commit 7e7ff87446
1 changed files with 27 additions and 0 deletions

27
pg_bak.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash
bakpath="/srv/backup"
count="5"
num=$count
cd $bakpath
while [ -a daily0.dump ]; do
if [ -a daily$num.dump ]; then
echo "moving daily$num.dump to daily$((num+1)).dump"
mv daily$num.dump daily$((num+1)).dump
fi
num=$((num-1))
done
echo "dumping postgresql dbs to a new daily0.dump"
sudo -u postgres pg_dumpall > daily0.dump
if [ -a daily$((count+1)).dump ]; then
rm daily$((count+1)).dump
echo "removing daily$((count+1)).dump"
fi
echo "done"
exit 0