"hello world"
article in Tech linux-unix-and-friends

Local rolling backups

Having a couple days worth of backup can be very useful.  I like to use rdiff-backup for the entire system, but I also use multiple rolling backup scripts that send data out to remote servers as well as local storage.

Below is a script that I've made for backing up mysql databases.


# path to backup,make sure directory exists first (no trailing slash)

# get dates into variables
dayofweek=`date +%a`
month=`date +%m`
weeknumber=`date +%V`

#backup database with password and username.
# add -uroot -psomepassword to indicate username and password.

/usr/bin/mysqldump --quote-names -A --add-drop-table | gzip > ${backup}/dbbackup${dayofweek}.sql.gz

if [ "$dayofweek" = "Fri" ]; then

        #if you want 1 extra backup every month (12 a year), use this one
        cp ${backup}/dbbackup${dayofweek}.sql.gz ${backup}/dbbackup${dayofweek}.${month}.sql.gz

        #if you want 1 backup every week (52 per year), use this one
        #cp ${backup}/dbbackup${dayofweek}.sql.gz ${backup}/dbbackup.${weeknumber}.sql.gz
        ls -l ${backup}
        exit 0

ls -l ${backup}


The script above would simply store local copies.  For remote backup you could use a command like scp or mime-construct (for sending out email).

mime-construct --to user@domain --subject "backup" --file "/path/to/file"

Now all you have to do is stick this script in your cron.daily folder to start backing up every night!
Created: 2005-12-23 12:13:19 Modified: 2006-10-30 22:52:54
/root sections/
>peach custard pie
>random tech

moon and stars

My brain

Visible Dave Project

destory this webpage; if you will.