From: Chris Koeritz Date: Sat, 12 Oct 2024 05:14:40 +0000 (-0400) Subject: added mirror flag removing extraneous dest files X-Git-Url: https://feistymeow.org/gitweb/?a=commitdiff_plain;h=f79b7b770d2485c08f510248542f61bb4d713121;p=feisty_meow.git added mirror flag removing extraneous dest files --- diff --git a/scripts/archival/general_updater.sh b/scripts/archival/general_updater.sh index baca195c..8e7cff95 100644 --- a/scripts/archival/general_updater.sh +++ b/scripts/archival/general_updater.sh @@ -38,6 +38,7 @@ function synch_directory_to_target() { local from="$1"; shift local to="$1"; shift + local extra_flag="$1"; shift sep @@ -51,7 +52,7 @@ function synch_directory_to_target() fi echo "synching from $from into $to" - netcp "$from"/* "$to"/ + netcp $extra_flag "$from"/* "$to"/ if [ $? -ne 0 ]; then echo "The synchronization of $from into $to has failed." return 1 @@ -65,6 +66,23 @@ function synch_directory_to_target() function update_archive_drive() { local target_folder="$1"; shift # where we're backing up to. + +#echo "remaining parms are: $*" + # implement a mirroring feature if they use the flag "--mirror". + # this turns on rsync --delete feature to remove things on the destination + # that are not on the source. + local RSYNC_EXTRAS="" + local mirror_parm="$1"; shift + if [ "$mirror_parm" == "--mirror" ]; then + RSYNC_EXTRAS="--delete" + echo " +NOTE: +Due to the presence of the '--mirror' flag on the command line, we are +adding rsync flags to mirror the source, which removes any files that +are on the destination but not on the source. +" + fi + local currdir # loop variable. sep @@ -78,7 +96,7 @@ function update_archive_drive() # synch all our targets. for currdir in $MAJOR_ARCHIVE_SOURCES; do - synch_directory_to_target "$currdir" "$target_folder/$(basename $currdir)"/ + synch_directory_to_target "$currdir" "$target_folder/$(basename $currdir)"/ $RSYNC_EXTRAS done sep