3 # $DragonFly: src/bin/cpdup/scripts/do_remote_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_remote_host <host> <level> > $remote_path/mirrors/<host>.log"
17 set level = "$argv[2]"
19 if ( ! -d $backup_nfs/$host ) then
20 echo "Host not found in $backup_nfs"
23 if ( ! -d $backup_path/mirrors/$host ) then
24 echo "No backup found for $host"
28 # Figure out the source directory
30 set source = `readlink $backup_path/mirrors/$host`
31 if ( "$source" == "" ) then
32 echo "No backup found for $host at $backup_path/mirrors/$host"
33 echo "or it was not a softlink"
37 # Figure out the hardlink optimized side directory on
41 if ( $level != 0 ) then
42 set hlbase = `ssh $remote_host -n "readlink ${remote_path}/mirrors/$host"`
43 if ( "$hlbase" == "" ) then
44 echo "Missing softlink at ${remote_host}:${remote_path}/mirrors/${host}"
45 echo "cannot proceed. Perhaps you did not run a level 0 with"
46 echo "the do_remote script to create the hardlink base and softlink?"
50 if ( "$hlbase" == "$source" ) then
51 echo "SUCCEEDED - NO NEW BACKUP SINCE LAST TIME"
56 # Figure out the target path and add prefixes
58 set basename = $source
59 set target = ${remote_host}:${remote_path}/mirrors/${source}
60 set source = $backup_path/mirrors/${source}
61 set hlbase = ${remote_path}/mirrors/${hlbase}
63 echo "---------- OFFSITE BACKUP OF $source ---------"
68 # Do the actual backup
75 echo "cpdup -i0 -s0 -I $source $target"
76 cpdup -i0 -s0 -I $source $target
77 if ( $status != 0 ) then
82 echo "cpdup -f -i0 -s0 -I -H $hlbase $source $target"
83 cpdup -f -i0 -s0 -I -H $hlbase $source $target
84 if ( $status != 0 ) then
89 echo "cpdup -i0 -s0 -I -H $hlbase $source $target"
90 cpdup -i0 -s0 -I -H $hlbase $source $target
91 if ( $status != 0 ) then
96 echo "UNKNOWN BACKUP LEVEL, USE ONLY 0-2"
101 if ( $failed == 0 ) then
102 ssh $remote_host -n "rm -f ${remote_path}/mirrors/$host; ln -s $basename ${remote_path}/mirrors/$host"