Skip to content

Instantly share code, notes, and snippets.

@lyndell

lyndell/backup-home

Last active Aug 29, 2015
Embed
What would you like to do?
Backup-home
#!/bin/bash
#
# Author: Lyndell
# URL: http://www.Lyndell.US/
# gist: https://gist.github.com/6f864b63759153eee197.git
#
#
#
# Quick script to backup the home directory in \*nix environment to other servers.
#
# Loop through multiple destrination. Multiple destinations just in case
# one or more becomes unavailable.
#
# INSTALLATION
#
# Destination servers are listed in `destlist.txt`. Particular
# login details are saved in `ssh.conf` for easy access in the
# `for` loop.
#
# Files to not backup in `exclude.txt`.
#
set -x
VERBOSE="vv"
VERBOSE=""
if [[ "$OSTYPE" == "linux-gnu" ]]; then
for I in `cat destlist.txt`
do
## $I is one hostname in destination list.
LOGFILE=~/Desktop/${I}.`date +%s`.log
rsync -a${VERBOSE} -e "ssh " \
--log-file=${LOGFILE} \
--exclude-from=exclude.txt \
--delete \
--delete-excluded \
~/ ${I}:BACKUP/`hostname`
done
else
# Unknown.
echo "Wow, that's a weird one.\n"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment