View Full Version : backup script

8th November 2004, 09:41 PM
hi, i have a backup script which goes as follows:

# Back-Up Directory
TIMESTAMP=`date +%Y%m%d_%H%M%S`; #Year_Month_Day_Hour_Minute_Second
/usr/bin/rsync --verbose --stats --recursive /server/Mail /server2/Mirror/
/usr/bin/rsync --verbose --stats --recursive /server/Documents /server2/Mirror/
/usr/bin/rsync --verbose --stats --recursive /server/Backup /server2/Mirror/
if [ $? -eq 0 ];then
echo "bk_OK_$TIMESTAMP" >> /home/ian/sync.log


designed to copy my important stuff to another hard drive.. but a problem that i have with it is when it runs... if i have deleted something the backup copy doesnt delete the same file.

any ideas how i can get around this? thanks.

8th November 2004, 09:47 PM
Isn't it the main reason for a backup, that the deleted files are not deleted in the backup directory?

8th November 2004, 09:53 PM
see your point on that one... i didnt think of it like that

was just wanting it as a copy of whats on the other drive incase of a failure etc.. but i think i will keep it as is now.
could just set it to have a clear out of that directory so that it starts fresh every month or so, so that it doesnt go wild on disk space.

8th November 2004, 09:57 PM
read through the man page of rsync. It is very interesting and might help you.


This tells rsync to delete any files on the receiving side that
arenít on the sending side. Files that are excluded from
transfer are excluded from being deleted unless you use

This option has no effect if directory recursion is not

This option can be dangerous if used incorrectly! It is a very
good idea to run first using the dry run option (-n) to see what
files would be deleted to make sure important files arenít

If the sending side detects any I/O errors then the deletion of
any files at the destination will be automatically disabled.
This is to prevent temporary filesystem failures (such as NFS
errors) on the sending side causing a massive deletion of files
on the destination. You can override this with the --ignore-
errors option.