We have a script that runs on a a data domain device, what I am being asked is if we can tie the completion of said script into that node being unmanaged for a set timeframe
#!/bin/bash
#Fail on any error. Don't want to break things unnecessarily.
# On second thought, don't do it. This breaks the script when rsync has some minor errors from open files and whatnot.
#set -e
#Time is the number of days old you'd like to keep.
TIME=2
# Copies is the number of concurrent copies
# 32 was able to get about ~8Gb
# 48 was only getting 5.5Gb
# 24 would sharktooth up to 8Gb, down to 3Gb
COPIES=32
# Source and destination mount points (local) and shares (remote)
SOURCE_MOUNT=/root/brad/source
SOURCE_SHARE=//uhidpadd01d/sqlfull
DEST_MOUNT=/root/brad/dest
DEST_SHARE=//uhdatadomain01r/backup
#Make yourself a nice header.
echo $(date) - ---------------------------------------------
echo $(date) - Time Delay: $TIME
echo $(date) - Concurrent Copies: $COPIES
echo $(date) - Source Share: $SOURCE_SHARE
echo $(date) - Destination Share: $DEST_SHARE
#Remove any (possibly) spurious mounts, then mount source and destination properly
if mountpoint -q $SOURCE_MOUNT; then
echo $(date) - Unmounting existing source.
umount -l $SOURCE_MOUNT
fi
echo $(date) - Mounting Source: $SOURCE_SHARE
mount -o credentials=$SOURCE_MOUNT/../creds.smb $SOURCE_SHARE $SOURCE_MOUNT
if mountpoint -q $DEST_MOUNT; then
echo $(date) - Unmounting existing destination.
umount -l $DEST_MOUNT
fi
echo $(date) - Mounting Destination: $DEST_SHARE
mount -o credentials=$SOURCE_MOUNT/../creds.smb $DEST_SHARE $DEST_MOUNT
# This may seem redundant, but without set -e we need to make absolutely sure that the filesytems are mounted,
# otherwise all sorts of bad juju apppears. So now we check if it's mounted, which returns a 0. So check for non-zero
# and if that's the case, just abort mission.
if ! mountpoint -q $SOURCE_MOUNT; then
echo $(date) - Source isn\'t mounted. Aborting mission.
exit
fi
if ! mountpoint -q $DEST_MOUNT; then
echo $(date) - Destination isn\'t mounted. Aborting mission.
fi
#Delete old data
echo $(date) - Deleting data older than $TIME days.
find $DEST_MOUNT -type f -mtime +$TIME -print0 | xargs -n1 -P128 -0 -I{} rm -f '{}'
#Make destination directory and goto source dir for copying
mkdir -p $SOURCE_MOUNT/sqlbu/
if pushd $SOURCE_MOUNT > /dev/nul
then
echo $(date) - Deletion finished. Directory change successful.
else
echo $(date) - Deletion finished. Move to $SOURCE_MOUNT failed. Abort mission.
exit
fi
#Run your actual copies
echo $(date) - Starting data copies from $SOURCE_MOUNT to $DEST_MOUNT
find -type f -mtime -$TIME -print0 | xargs -n1 -P$COPIES -0 -I{} rsync -a --whole-file --ignore-existing --inplace --relative '{}' "$DEST_MOUNT"
echo $(date) - Finished copying data.
#Clean up your mountpoints
echo $(date) - Unmounting Source.
umount -l $SOURCE_MOUNT
echo $(date) - Unmounting Destination.
umount -l $DEST_MOUNT
Since I know nothing about bash and how to tie the two together, I am hoping that one of you can assist.