Last active
August 29, 2015 14:05
-
-
Save lyndell/6f864b63759153eee197 to your computer and use it in GitHub Desktop.
Backup-home
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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