Created
October 27, 2013 16:35
-
-
Save tkmtmkt/7184659 to your computer and use it in GitHub Desktop.
backup by rsync
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 | |
# | |
# target server | |
# /root/.ssh/authorized_keys | |
# | |
# backup server | |
# ssh-keygen -f .ssh/backup -C backup | |
# ssh-copy-id -i .ssh/backup.pub $TARGET | |
# | |
# /root/.ssh/config | |
# /root/.ssh/backup | |
# /root/.ssh/backup.pub | |
# /root/.ssh/known_hosts | |
# | |
# /home/backups/brown/doBackup | |
# | |
BASE=$(cd $(dirname $0);pwd) | |
TARGET=brown | |
LOGFILE="$BASE/rsync_${TARGET}_$(date +"%Y%m%d%H%M%S").log" | |
while read object | |
do | |
src="$TARGET:$object" | |
dst="$(dirname "$BASE$object")" | |
if [ ! -d "$dst" ] ; then | |
mkdir -p "$dst" | |
fi | |
rsync -avz --delete "$src" "$dst" 2>&1 | tee -a $LOGFILE | |
done <<EOS | |
/etc/network | |
/etc/hosts | |
/etc/ssh | |
/etc/environment | |
/home | |
EOS | |
# vim: set ts=2 sw=2 et: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment