Results 1 to 7 of 7
Threaded View
-
05-28-2005, 02:00 PM #1Web Hosting Guru
- Join Date
- Sep 2003
- Location
- UK
- Posts
- 345
Help with backup script and cronjob
Hi,
My query is split into two sections, one with cronjob help and the other with shell backup script.
First Part
I have a domain on my server which needs to be backed up every few hours. I was thinking of doing it every 6 hours.
Would the cronjob be:
Code:0,6,12,18 * * * * /root/backupacorn.sh > /dev/null 2>&1
Second Part
My backup script currently rsync's all files in users home dir and dumps a mysql file onto the backup hard drive.
Currently my file looks like this:
Code:#!/bin/sh #Setup directory BACKUPDIR=`date +%d`'-'`date +%m`'-'`date +%y`'--'`date +%T` #Create directory mkdir /backup/acornbackup/html/$BACKUPDIR/ chown acorn:acorn /backup/acornbackup/html/$BACKUPDIR chmod 655 /backup/acornbackup/html/$BACKUPDIR #Rsync data to new directory rsync -a /home/acorn/ /backup/acornbackup/html/$BACKUPDIR/ #Create directory mkdir /backup/acornbackup/mysql/$BACKUPDIR/ chown acorn:acorn /backup/acornbackup/mysql/$BACKUPDIR chmod 655 /backup/acornbackup/mysql/$BACKUPDIR #Dump mysql data mysqldump -uuser -ppass acorn_data > /backup/acornbackup/mysql/$BACKUPDIR/acorn_data.sql #Check permissions chown acorn:acorn -R /backup/acornbackup/ chmod 655 -R /backup/acornbackup/
What i want to do is keep the last days backups (if backups are done every 6 hours, the last 4).
Also i would like to further break it up into days (e.g when a day has passed the final backup is placed into a directory with just the date as a name) I would then like to keep the last 7 days worth of backups.
I can then expand it to include week directories, month directories and year directories, however once i know how to do the days ill be able to work out the rest.
Can anyone help or point me in the right direction on where to look for help?
ThanksCentation Web Services
Bristol based web design
Offering website design, SEO, website hosting, website development and domain registration.