1 minute read

everyone needs a rsync backup script at some point in their life ;)   this is the one i wrote in the last couple minutes/hours/days/years ...

it syncs a local folder with a folder remotely hosted over ssh.

note: its important that variables dont have whitespaces around equality sign. furthermore, no whitespaces after linebreaks (\)

[code language="bash" padlinenumbers="true"]
#!/bin/bash

SOURCE="a/"

DEST_HOST="my-page.com"
DEST_PATH="~/tmp"

# rsync options
# a: archive mode
# partial: dont delete partially copied files
# append-verify: append to partial files and then verify by checksums

rsync -a \
--partial \
--append-verify \
-e "ssh" \
$SOURCE \
${DEST_HOST}:${DEST_PATH}
[/code]