Last active
November 5, 2015 13:39
-
-
Save captbrogers/86033ef55b488c828c9d to your computer and use it in GitHub Desktop.
Rsync for snapshot
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 | |
# Basic snapshot-style rsync backup script | |
# Taken from https://wiki.archlinux.org/index.php/Rsync#Snapshot_backup | |
# Config | |
## archive, show progress, in human readable sizes | |
OPT="-aPh" | |
LINK="--link-dest=/snapshots/username/last/" | |
SRC="/home/username/" | |
SNAP="/snapshots/username/" | |
LAST="/snapshots/username/last" | |
date=`date "+%Y-%b-%d:_%T"` | |
EXCLUDE="--exclude='rsync-exclude.txt' --exclude-from 'rsync-exclude.txt'" | |
# Run rsync to create snapshot | |
rsync $OPT $LINK $EXCLUDE $SRC ${SNAP}$date | |
# Remove symlink to previous snapshot | |
rm -f $LAST | |
# Create new symlink to latest snapshot for the next backup to hardlink | |
ln -s ${SNAP}$date $LAST |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment