'Not intending to hijack this thread, but I decided it would not hurt to post my rsync BASH file for people to see and use as they see fit:
The /etc/gadmin-rsync/inhibit file needs to contain some text. If it contains the text "CRC", then the rsync process will do a full checksum on all the files. Any other text in the file will prevent the checksum.
Bash:
#!/bin/bash
RunFile=/var/run/gadmin-rsync-Main.run # Run file to prevent multiple instances of the script running
LogFile=/var/log/gadmin-rsync/gadmin-rsync-Main.log # Log file to keep track of backup sessions and / or failures
grep -iq true /etc/gadmin-rsync/inhibit && exit 0 # Check to make sure CRC is properly set or unset
CRC=""
grep -iq crc /etc/gadmin-rsync/inhibit && CRC=--checksum # Check to see if checksum is required (takes much, much longer)
thisPID=$$
START_TIME=`date +%Y-%m-%d_%H:%M:%S`;
noMount=1
Running=1
mount | grep -q /Backup && noMount=0 # Check to see the RAID array is mounted
if [[ -s $RunFile ]]; # Sanity check
then
ps -fp $( cat $RunFile ) > /dev/null
if [ $? -eq 0 ]
then
Running=0
else
echo $thisPID > $RunFile
fi
else
echo $thisPID > $RunFile
fi
# Log any errors; if no errors, then run the rsync process
if [ $noMount -eq 1 ]; then
echo -n File_system_not_mounted:___ >> $LogFile
MISSING_PATH=1
elif [ ! -e '/Backup/Recordings' ]; then
MISSING_PATH=1
echo -n Missing_destination_path:__ >> $LogFile
elif [ $Running -eq 0 ]; then
MISSING_PATH=1
echo -n Instance_of_rsync_running:_ >> $LogFile
else
MISSING_PATH=0
rsync --archive --progress --human-readable --verbose --stats --exclude Firefox/ --skip-compress=* $CRC -e "ssh -l root -p 22" root@RAID-Server:'/RAID/' '/Backup'
fi
# Post run time or failures to log after rsync runs.
if [ $? -eq 0 ] && [ $MISSING_PATH -eq 0 ]; then
STOP_TIME=`date +%Y-%m-%d_%H:%M:%S`;
echo "$START_TIME $STOP_TIME Backup successful: Source: [RAID-Server/RAID/] Destination: [/Backup]" >> $LogFile
else
STOP_TIME=`date +%Y-%m-%d_%H:%M:%S`;
echo "$START_TIME $STOP_TIME Backup failure: Source: [RAID-Server/RAID/] Destination: [/Backup]" >> $LogFile
fi
[[ $Running -eq 1 ]] && rm $RunFile
The /etc/gadmin-rsync/inhibit file needs to contain some text. If it contains the text "CRC", then the rsync process will do a full checksum on all the files. Any other text in the file will prevent the checksum.
Last edited: