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/
(the chmod 655 is because the backups are to be viewable from a browser until i setup a backup system)

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?

Thanks