Skip to content

Instantly share code, notes, and snippets.

@belst
Last active Apr 15, 2019
Embed
What would you like to do?
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