Barry Samuels wrote:
I have two hard drives in my computer. One is the working drive and the other is a backup copy of the working drive. The backup drive is updated once a day where files have changed.
I want to be able to run a script, at intervals, which will check all the files on the backup drive and delete those which are no longer present on the working drive.
The root directory on the working drive will, of course, be / and the root of the backup drive will be something like /mnt/point.
I'm having considerable difficulty in working out how to do this.
Some help would be very welcome from the scripting experts.
Take a look at rdiff-backup. It does what you want, but also saves versions so you can restore deleted files, and/or previous versions. In other words, the main backup reflects the contents of your "mirrored" drive, but elsewhere in the archive it stores versioning info such that deleted files can be restored.
See: http://www.nongnu.org/rdiff-backup/
From that page:
"What is it?
rdiff-backup backs up one directory to another, possibly over a network. The target directory ends up a copy of the source directory, but extra reverse diffs are stored in a special subdirectory of that target directory, so you can still recover files lost some time ago. The idea is to combine the best features of a mirror and an incremental backup. rdiff-backup also preserves subdirectories, hard links, dev files, permissions, uid/gid ownership, modification times, extended attributes, acls, and resource forks. Also, rdiff-backup can operate in a bandwidth efficient manner over a pipe, like rsync. Thus you can use rdiff-backup and ssh to securely back a hard drive up to a remote location, and only the differences will be transmitted. Finally, rdiff-backup is easy to use and settings have sensical defaults."
Gentoo has an ebuild for this. We use it extensively over SSH using keys to back up remote sites.
Cheers, Laurie.