scripts/backup/obstinate-rsync.sh

38 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
#
# backup.sh, Copyright © 2011 Matteo Cypriani <mcy@lm7.fr>
#
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details.
#
# Transfers a single directory to a remote host using rsync. The
# transfer is retried until it succeeds.
# Any of the protocol supported by rsync, with the "://" (comment-out to use
# SSH):
#PROTO=rsync://
# Remote backup host:
HOST=vicious
# Destination of the backup on the remote host:
REMOTE_DIR=/backup
# Local directory to backup:
LOCAL_DIR="$HOME"
# File where the excludes patterns are stored (one per line):
EXCLUDES="$HOME/.backup-excludes"
# Remove --delete to keep the locally deleted files on the remote host (you can
# also set to --delete-after or --delete-before):
RSYNC_OPTS="-av --delete"
# shellcheck disable=2086
until rsync $RSYNC_OPTS --exclude-from="$EXCLUDES" \
"$LOCAL_DIR" "${PROTO}${HOST}:$REMOTE_DIR"
do
echo "Retrying..."
done
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4