Automatic archival to rsync.net
·1 min
Create an archival script #
.rsync-archival-script.sh should look something like the following. Also, do a chmod +x .rsync-archival-script.sh
.
#!/bin/sh
CMD=/usr/bin/rsync
SRC=/media/unencrypted_drive/SharedFolder/
DST_NAMESPACE=raspberry-pi
EXCLUDES_LOC=/tmp/rsync-homedir-excludes.txt
wget https://raw.githubusercontent.com/rubo77/rsync-homedir-excludes/master/rsync-homedir-excludes.txt -O $EXCLUDES_LOC
cat >> $EXCLUDES_LOC << 'EOF'
.Trash
._*
/Library
ParkingSpace
EOF
DST=$DST_NAMESPACE$SRC
ssh de1682@de1682.rsync.net mkdir -p $DST
echo BEGIN `date`
# TODO: check `-og` parameters as well.
$CMD \
-azPH \
--exclude-from=$EXCLUDES_LOC \
--delete-excluded \
--xattrs \
--acls \
$SRC de1682@de1682.rsync.net:$DST
curl -fsS -m 10 --retry 5 -o /dev/null https://hc-ping.com/.../$?
echo END `date`
Schedule the script #
Install this by running crontab -e
on Raspberry Pi:
0 1 * * * /home/pi/.rsync-archival-script.sh >> /tmp/rsync-backup.log 2>&1
Or with sudo
on Mac:
0 18 * * * /Users/ketan/.rsync-archival-script.sh >> /tmp/rsync-backup.log 2>&1
Resources #
- Good one on how to use exclusion patterns: https://askubuntu.com/a/349625
- rsync.net resources: