Create Incremental Backup Script Using rsync

Status
Not open for further replies.

Keetawat

Dabbler
Joined
Jan 4, 2017
Messages
11
Dear All,
Can you please show or explain me for how to create daily incremental backup script by using the rsync.
Here is my script

#!/bin/sh
#Created By Keetawat Chaichompoo.
# emails a status report
(
echo "To: EMAIL_RECIPIENTS"
echo "Subject: SUBJECT"
echo " "
) > /var/mail_rsync
echo " " >> /var/mail_rsync
LastFolder=`cat /SCRIPT_FOLDER/last_folder.txt`
YesterdayDate=`date -v -1d +%F`
#TodayDate=`date +%F`
TodayDate=`date +%F%H%M%S`
Source="PATH_OF_SOURCE_FILE_FOLDER"
Destination="PATH_OF_DESTINATION_BACKUP/$TodayDate"
DestinationLink="PATH_OF_RECENT_FOLDER/$LastFolder"
Options="-avrh --delete --ignore-errors --compare-dest=$DestinationLink --exclude-from SCRIPT_FOLDER/exclude_list.txt"
echo "###Start Rsync Activity $(date)##" >> /var/mail_rsync
echo "Source : $Source" >> /var/mail_rsync
echo "Target : $Destination" >> /var/mail_rsync
echo "Executing : rsync $Options $Source $Destination" >> /var/mail_rsync
rsync $Options $Source $Destination >> /var/mail_rsync
echo "###Finished Rsync Activity $(date)###" >> /var/mail_rsync
sendmail -t < /var/mail_rsync
CountLine=`cat /var/mail_rsync|wc -l`
if [ $CountLine -eq 14 ];
then
#echo "Nothing"
else
echo $TodayDate > SCRIPT_FOLDER/last_folder.txt
fi
exit 0

For any of suggestions are welcome.
Thank you in advance.
 

droeders

Contributor
Joined
Mar 21, 2016
Messages
179
Dear All,
Can you please show or explain me for how to create daily incremental backup script by using the rsync.

Most people on this forum would recommend using the built-in ZFS mechanisms for snapshots.

That said, if you're set on using rsync, I would look into rsnapshot rather than re-inventing the wheel with your script:

http://rsnapshot.org/
 
Status
Not open for further replies.
Top