Mirror change tracking
From FBSD_tips
Keeping deleted or changed files from a mirror source using rsync.
Sometimes I want to have copies of the changed or deleted files from a filesystem I am mirroring with rsync, and keep track of when they were altered or over-written. Here is a script snippet to accomplish this.
First I grabthe date, in separate pieces :
YR=`date "+%Y"` MN=`date "+%m"` DY=`date "+%d"`
Then let's make the directory that will hold the changed files :
mkdir -p /mirrors/mitrror1/changes/${YR}/${MN}/${DY}
Then use the --backup and --backup-dir options of rsync to populate it while we (re)sync the mirror :
rsync -avP \
--backup \
--backup-dir=/mirrors/mitrror1/changes/${YR}/${MN}/${DY}
--delete \
rsyncuser@[remote host]:/ /mirrors/mitrror1/root/
Rsyncuser is talked about in this article Rsync mirror without root.
Replace [remote host]:/ with the host and file system you are mirroring.
Now the live mirror will be in /mirrors/mitrror1/root/ and daily changes (assuming that you run this daily) will be in a hierarchy sorted by year / month / day starting at /mirrors/mitrror1/changes/.
Gongo 20:35, 26 September 2007 (UTC)
