#!/bin/bash function echoe { echo [`date +"%Y-%m-%d %H:%M:%S.%N"` - incremental.sh] $@ } echoe echoe -------------------------------- echoe Incremental sync script started. echoe -------------------------------- STARTTIME=$(date +%s.%N) #If the folder is not empty if [ ! -f /root/scripts/.incremental.lck ] then touch /root/scripts/.incremental.lck if [ -e "/root/ramdisk/spigot.jar" ] then echoe Contents exist, creating a hard copy. rsync -q -av --delete --force --recursive /root/ramdisk /mnt/2T/Backup/Incremental if [ $? -gt 0 ] then echoe Well, something went wrong with the copy... Aborting. else echoe Incremental copy sync went perfectly smooth. fi else echoe Nothing is in the ramdisk folder ! Copying from the last incremental data. rsync -q -av --recursive --force /mnt/2T/Backup/Incremental/ramdisk/ /root/ramdisk/ if [ $? -gt 0 ] then echoe The copy went wrong, aborting. else echoe Successfully recreated the ramdisk folder from the latest incremental data. fi fi else echoe Already running... fi rm /root/scripts/.incremental.lck ENDTIME=$(date +%s.%N) DIFF=$(echo "$ENDTIME - $STARTTIME" | bc) echoe -------------------------------- echoe Incremental sync script was done echoe in $DIFF seconds. echoe -------------------------------- echoe