Tuesday, January 25, 2005

Parts of Deepfreeze

This is a part of the deepfreeze program. Note that I'm using diff -ru to generate the differences between the Nth snapshot and today's snapshot. The really nice thing is I account for two things both that the target is different than the current one and that the file is now unique [ie having been deleted since the Nth snapshot was taken]

open(FP,"diff -ru --brief $SOURCE $TARGET 2>/dev/null |");
open(FP2, "|(cd $TARGET ; tar jcf $DESTINATION$SCRUBBED_TARGET.$SUFFIX -T -)");

while (){
s/: /\//g;
#this is if the file that was in TARGET is different than SOURCE
if (/^Files .* and (.*) differ$/){
$tmp = $1;
$tmp =~ s/$TARGET/\./;
print FP2 $tmp,"\n";
}
#this is if the file no longer lives in SOURCE at all
if (/^Only in ($TARGET.*)\n/){
$tmp = $1;
$tmp =~ s/$TARGET/\./;
print FP2 $tmp,"\n";
}
}

No comments: