Skip to content

Instantly share code, notes, and snippets.

@belst
Last active April 15, 2019 14:25
Show Gist options
  • Save belst/b0dbbf60b13b0e69bda21d34e72b826b to your computer and use it in GitHub Desktop.
Save belst/b0dbbf60b13b0e69bda21d34e72b826b to your computer and use it in GitHub Desktop.
Incremental rsync backup script
#!/usr/bin/env bash
SOURCE=/home/belst/
TARGET="backup:~/backup/home/belst/" # Trailing / is needed
TODAY=$(date +%Y-%m-%d)
ssh backup mkdir -p "${TARGET#*:}${TODAY}"
rsync -avR --delete "${SOURCE}" "${TARGET}${TODAY}/" --link-dest="${TARGET#*:}last"
ssh backup ln -nsf "${TARGET#*:}${TODAY}" "${TARGET#*:}last"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment