3 # $DragonFly: src/bin/cpdup/scripts/do_mirror_host,v 1.2 2006/09/21 00:18:13 dillon Exp $
7 if ( "$argv" == "" ) then
8 echo "Specify host mounted in $backup_nfs (e.g. 'apollo'), and level."
9 echo "Level 0 - full backup, do not use hardlink trick"
10 echo "Level 1 - full backup, use hardlink trick but verify each file"
11 echo "Level 2 - full backup, use hardlink trick and stat shortcut"
12 echo "./do_mirror_host <host> <level> > $backup_path/mirrors/<host>.log"
16 set date = `date "+%Y%m%d"`
18 set level
= "$argv[2]"
20 if ( ! -d $backup_nfs/$host ) then
21 echo "Host not found in $backup_nfs"
24 if ( ! -d $backup_path/mirrors
/$host ) then
25 mkdir
$backup_path/mirrors
/$host
28 # Target directory for this backup
30 set target
= $host.
$date
31 if ( ! -d $backup_path/mirrors
/$target ) then
32 mkdir
-p $backup_path/mirrors
/$target
39 rm -f $backup_path/mirrors
/$target/{INPROGRESS
,FAILED
,SUCCEEDED
}
40 if ( -f $backup_path/mirrors
/$host.log
) then
41 ln $backup_path/mirrors
/$host.log
$backup_path/mirrors
/$target/INPROGRESS
43 echo "NO LOG RECORDED" > $backup_path/mirrors
/$target/INPROGRESS
46 # Iterate subdirectories. Each subdirectory is considered to be a separate
49 foreach fs
( $backup_nfs/$host/* )
53 if ( ! -d $backup_path/mirrors
/$target/$dirname ) then
54 mkdir
-p $backup_path/mirrors
/$target/$dirname
56 if ( -f $fs/NOT_MOUNTED
) then
63 echo "cpdup -i0 -s0 -I $fs $backup_path/mirrors/$target/$dirname"
64 cpdup
-i0 -s0 -I $fs $backup_path/mirrors
/$target/$dirname
65 if ( $status != 0 ) then
70 echo "cpdup -f -i0 -s0 -I -H $backup_path/mirrors/$host/$dirname $fs $backup_path/mirrors/$target/$dirname"
71 cpdup
-f -i0 -s0 -I -H $backup_path/mirrors
/$host/$dirname $fs $backup_path/mirrors
/$target/$dirname
72 if ( $status != 0 ) then
77 echo "cpdup -i0 -s0 -I -H $backup_path/mirrors/$host/$dirname $fs $backup_path/mirrors/$target/$dirname"
78 cpdup
-i0 -s0 -I -H $backup_path/mirrors
/$host/$dirname $fs $backup_path/mirrors
/$target/$dirname
79 if ( $status != 0 ) then
84 echo "UNKNOWN BACKUP LEVEL, USE ONLY 0-2"
92 # If we succeeded then set up a softlink so a higher level incremental
93 # backup can locate the most recent version of the previous level,
94 # another so we can locate the most recent backup period, and also
95 # rename the log file.
97 if ( $failed == 0 ) then
98 rm -f $backup_path/mirrors
/$host
99 ln -s "$host.$date" $backup_path/mirrors
/$host
100 mv $backup_path/mirrors
/$target/{INPROGRESS
,SUCCEEDED
}
104 mv $backup_path/mirrors
/$target/{INPROGRESS
,FAILED
}