added postgresql backup script
This commit is contained in:
parent
d49b956fff
commit
7e7ff87446
|
@ -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
|
Loading…
Reference in New Issue