Stupid-Silly Back-up Script 2 comments

Posted by robon November 21, 2007

Went looking for this script again just now. I’m putting here as an entry for faster reference. Nothing ground-breaking here, just a stupid-silly back-up script:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
cardero:~/bin pmcweb$ cat backup-pmc-site.sh 
#!/bin/sh

BACKUP_BASE=/users/home/pmcweb/backups
BACKUP_DIR=$BACKUP_BASE/pmcweb_`date +%m-%d-%Y`

if [ ! -e $BACKUP_DIR ]; then
    echo "making back-up directory:"
    echo "$BACKUP_DIR"
    /bin/mkdir $BACKUP_DIR
    echo "dumping database..."
    /usr/bin/mysqldump prn -u USER -P PASSWORD > $BACKUP_DIR/db-dump_`date +%m-%d-%Y`.sql
fi

# nuke back-ups older then 5 days:
find $BACKUP_BASE/pmcweb_* -ctime +5 -maxdepth 0 -print | xargs rm -rf

Comments

Leave a response

  1. Jeremy KemperNovember 21, 2007 @ 07:03 PM

    You want rsnapshot.. bad. http://www.rsnapshot.org/

  2. RobNovember 22, 2007 @ 08:46 AM

    @Jeremy Kemper: rsnapshot is exactly what I need… Thanks!

    This is the second time you’ve pointed out the perfect tool to replace my not-so-optimal solution. Keep it up. :)