Dave Horner's Website - Yet another perspective on things...
79 guests
Rough Hits : 2732839
how did u find my site?

If you can't explain it simply, you don't understand it well enough.
--Albert Einstein
\begin{bmatrix} 1 & 0 & \ldots & 0 \\ 0 & 1 & 0 & \vdots \\ \vdots & 0 & \ddots & 0\\ 0 & \ldots & 0 & 1_{n} \end{bmatrix}

# Local rolling backups

Friday, 23 December 2005 07:13
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.
<br/>
#!/bin/bash<br/>
<br/>
# path to backup,make sure directory exists first (no trailing slash)<br/>
backup=/path/to/backup<br/>
<br/>
# get dates into variables<br/>
dayofweek=date +%a<br/>
month=date +%m<br/>
weeknumber=date +%V<br/>
<br/>
<br/>
/usr/bin/mysqldump --quote-names -A --add-drop-table | gzip > ${backup}/dbbackup${dayofweek}.sql.gz<br/>
<br/>
if [ "$dayofweek" = "Fri" ]; then<br/> <br/> #if you want 1 extra backup every month (12 a year), use this one<br/> cp${backup}/dbbackup${dayofweek}.sql.gz${backup}/dbbackup${dayofweek}.${month}.sql.gz<br/>
<br/>
#if you want 1 backup every week (52 per year), use this one<br/>
#cp ${backup}/dbbackup${dayofweek}.sql.gz ${backup}/dbbackup.${weeknumber}.sql.gz<br/>
ls -l ${backup}<br/> exit 0<br/> fi<br/> <br/> ls -l${backup}<br/>
<br/>
exit<br/>

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!
Last Updated on Monday, 30 October 2006 17:52