#!/bin/bash #Website Backup Script #Todays date in ISO-8601 format: DAY0=`date -I` #Yesterdays date in ISO-8601 format: DAY1=`date -I -d "1 day ago"` #The source directory: SRC="/home/" #The target directory: TRG="/zewHDD/rsync/$DAY0" #The link destination directory: LNK="/zewHDD/rsync/$DAY1" #The rsync options: OPT="-avh --delete --link-dest=$LNK" #Execute the backup rsync --exclude=tmp --exclude=admin --exclude=mysql $OPT $SRC $TRG #29 days ago in ISO-8601 format DAY29=`date -I -d "29 days ago"` #Delete the backup from 29 days ago, if it exists if [ -d /zewHDD/rsync/$DAY29 ] then rm /zewHDD/rsync/$DAY29 fi