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.
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.