Skip to content

Instantly share code, notes, and snippets.

@kevashcraft kevashcraft/daily_backup
Last active Dec 2, 2018

Embed
What would you like to do?
Recursive backup w rsync - bash script
#!/bin/bash
DESTINATION="/Backup"
SOURCE="/var/www"
#Todays date in ISO-8601 format:
DAY0=`date -I`
#Previous backup date:
DAY1=`find $DESTINATION/* -type d -prune -not -wholename "*lost+found*" | tail -1`
#The target directory:
TRG="$DESTINATION/$DAY0"
#The link destination directory:
LNK="$DAY1"
#The rsync options:
OPT="-avh --delete --link-dest=$LNK"
#Execute the backup
rsync $OPT $SOURCE $TRG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.