Skip to content

Instantly share code, notes, and snippets.

@frozencemetery
Created May 19, 2013 16:36
Show Gist options
  • Save frozencemetery/5608177 to your computer and use it in GitHub Desktop.
Save frozencemetery/5608177 to your computer and use it in GitHub Desktop.
Simple rsync-based backup script.
#!/bin/sh
date=$(date "+%Y-%m-%dT%H:%M:%S")
MTPT=/mnt/Backup
SCWD=/root/
BASEDIR=/
rsync -avxzP \
--delete-excluded --exclude-from="${SCWD}/exclude" \
--link-dest="${MTPT}/Backups/current" \
"${BASEDIR}" "${MTPT}/Backups/incomplete-${date}" \
&& mv "${MTPT}/Backups/incomplete-${date}" "${MTPT}/Backups/back-${date}" \
&& rm -f "${MTPT}/Backups/current" \
&& ln -s "${MTPT}/Backups/back-${date}" "${MTPT}/Backups/current"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment