Skip to content

Instantly share code, notes, and snippets.

@lyndell
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lyndell/6f864b63759153eee197 to your computer and use it in GitHub Desktop.
Save lyndell/6f864b63759153eee197 to your computer and use it in GitHub Desktop.
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