Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/sh
PATH=/bin:/usr/bin
HOME=~
HOSTNAME=$(hostname)
USER=$(echo "${HOSTNAME}" | sed "s/\.tucha13\.net$//")
INCLUDES="/etc/rsync-backup.includes"
EXCLUDES="/etc/rsync-backup.excludes"
BSERVERADDR="backup.z2.tucha13.net"
BSERVERPORT="22"
DATE=$(date +%Y.%m.%d-%H:%M:%S)
[ -e ${EXCLUDES} ] || touch ${EXCLUDES}
rsync \
--rsh="ssh -p ${BSERVERPORT} -i ${HOME}/.ssh/id_rsa.backup" \
--verbose \
--archive \
--relative \
--perms \
--force \
--ignore-errors \
--delete \
--backup \
--backup-dir="~/${HOSTNAME}-${DATE}" \
--exclude-from="${EXCLUDES}" \
$(cat "${INCLUDES}" | sed -r -n "s/^[[:space:]]*([^#]+)([[:space:]]*#.*)?$/\1/gp") \
"${USER}@${BSERVERADDR}:~/${HOSTNAME}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment