Google
 

« Xinstall | メイン | OpenPNEのcron »

2009年09月02日

●database backup

#!/bin/sh

keepday=30

dest=/var/share/backup

/usr/bin/pg_dump cms_production > $dest/pgsql-backup

srcfile=$dest/pgsql-backup

timestamp=`date +%Y%m%d`
old_date=`date "-d$keepday days ago" +%Y%m%d`

bkfile=$dest/$timestamp.tar.gz

tar zcvf $bkfile $srcfile > /dev/null 2>&1

if [ $? != 0 -o ! -e $bkfile ]; then
echo "backup faild -- ($srcfile)"
exit 1
fi

rmfile=$dest/$old_date.tar.gz

if [ -e $rmfile ]; then
rm -f $rmfile
fi

rm -f $dest/pgsql-backup


#database backup
29 0 * * * /var/www/dbbackup.sh > /dev/null 2>&1

トラックバックURL

このエントリーのトラックバックURL:
http://www.fatcat-hosting.net/mt-tb.cgi/178