From a05b5f9b08cd36ac2df5871787af502f89b049b0 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Thu, 21 Sep 2006 00:18:13 +0000 Subject: [PATCH] Fix a bug in the script softlink code. The softlinks were not being properly updated because 'ln -sf' creates a softlink in the directory pointed to by the existing softlink rather then replacing the existing softlink. --- bin/cpdup/BACKUPS | 17 +++++++++++------ bin/cpdup/scripts/do_mirror_host | 5 +++-- bin/cpdup/scripts/do_remote_host | 4 ++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/bin/cpdup/BACKUPS b/bin/cpdup/BACKUPS index b893012eb1..8c3513a75c 100644 --- a/bin/cpdup/BACKUPS +++ b/bin/cpdup/BACKUPS @@ -1,4 +1,4 @@ -$DragonFly: src/bin/cpdup/BACKUPS,v 1.1 2006/09/16 21:57:08 dillon Exp $ +$DragonFly: src/bin/cpdup/BACKUPS,v 1.2 2006/09/21 00:18:11 dillon Exp $ INCREMENTAL BACKUP HOWTO @@ -72,10 +72,14 @@ $DragonFly: src/bin/cpdup/BACKUPS,v 1.1 2006/09/16 21:57:08 dillon Exp $ cpdup -i0 -s0 /nfs/box1/var /backup/mirrors/box1.${date}/var Create a softlink to the most recently completed backup, which is your - level 0 backup. + level 0 backup. Note that using 'ln -sf' will create a link in the + subdirectory pointed to by the current link, not replace the current + link. 'ln -shf' can be used to replace the link but is not portable. + 'mv -f' has the same problem. sync - ln -fs /backup/mirrors/box1.${date} /backup/mirrors/box1 + rm -f /backup/mirrors/box1 + ln -s /backup/mirrors/box1.${date} /backup/mirrors/box1 PART 3 - DO AN INCREMENTAL BACKUP @@ -102,7 +106,8 @@ $DragonFly: src/bin/cpdup/BACKUPS,v 1.1 2006/09/16 21:57:08 dillon Exp $ if the cpdup's for all the partitions for that client have succeeded. That way the next incremental backup will be based on the previous one. - ln -fs /backup/mirrors/box1.${date} /backup/mirrors/box1 + rm -f /backup/mirrors/box1 + ln -s /backup/mirrors/box1.${date} /backup/mirrors/box1 Since these backups are mirrors, locating a backup is as simple as CDing into the appropriate directory. If your filesystem has a @@ -169,7 +174,7 @@ $DragonFly: src/bin/cpdup/BACKUPS,v 1.1 2006/09/16 21:57:08 dillon Exp $ if ( $status == 0 ) then ssh remote.box -n \ - "ln -fs /backup/mirrors/$latest /backup/mirrors/box1" + "rm -f /backup/mirrors/box1; ln -s /backup/mirrors/$latest /backup/mirrors/box1" endif Incremental backups can be accomplished using the same cpdup command, @@ -187,7 +192,7 @@ $DragonFly: src/bin/cpdup/BACKUPS,v 1.1 2006/09/16 21:57:08 dillon Exp $ -i0 -s0 /backup/mirrors/$latest remote.box:/backup/mirrors/$latest if ( $status == 0 ) then ssh remote.box -n \ - "ln -fs /backup/mirrors/$latest /backup/mirrors/box1" + "rm -f /backup/mirrors/box1; ln -s /backup/mirrors/$latest /backup/mirrors/box1" endif Cleaning out the remote directory works the same as cleaning out the LAN diff --git a/bin/cpdup/scripts/do_mirror_host b/bin/cpdup/scripts/do_mirror_host index 0d2e153e47..a733de3196 100755 --- a/bin/cpdup/scripts/do_mirror_host +++ b/bin/cpdup/scripts/do_mirror_host @@ -1,6 +1,6 @@ #!/bin/csh # -# $DragonFly: src/bin/cpdup/scripts/do_mirror_host,v 1.1 2006/09/16 21:57:10 dillon Exp $ +# $DragonFly: src/bin/cpdup/scripts/do_mirror_host,v 1.2 2006/09/21 00:18:13 dillon Exp $ source params @@ -95,7 +95,8 @@ end # rename the log file. # if ( $failed == 0 ) then - ln -sf "$host.$date" $backup_path/mirrors/$host + rm -f $backup_path/mirrors/$host + ln -s "$host.$date" $backup_path/mirrors/$host mv $backup_path/mirrors/$target/{INPROGRESS,SUCCEEDED} sync echo "SUCCEEDED" diff --git a/bin/cpdup/scripts/do_remote_host b/bin/cpdup/scripts/do_remote_host index a50278720b..e1913bd2ea 100755 --- a/bin/cpdup/scripts/do_remote_host +++ b/bin/cpdup/scripts/do_remote_host @@ -1,6 +1,6 @@ #!/bin/csh # -# $DragonFly: src/bin/cpdup/scripts/do_remote_host,v 1.1 2006/09/16 21:57:10 dillon Exp $ +# $DragonFly: src/bin/cpdup/scripts/do_remote_host,v 1.2 2006/09/21 00:18:13 dillon Exp $ source params @@ -99,7 +99,7 @@ default: endsw if ( $failed == 0 ) then - ssh $remote_host -n "ln -sf $basename ${remote_path}/mirrors/$host" + ssh $remote_host -n "rm -f ${remote_path}/mirrors/$host; ln -s $basename ${remote_path}/mirrors/$host" sync echo "SUCCEEDED" exit 0 -- 2.41.0