Last active
December 2, 2018 22:43
-
-
Save kevashcraft/52887499775297803890 to your computer and use it in GitHub Desktop.
Recursive backup w rsync - bash script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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