Last active
August 20, 2016 22:00
-
-
Save reo7sp/0253c1e0952df9fb0618c56bfd6d3d97 to your computer and use it in GitHub Desktop.
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 | |
sshport=22 | |
sshcert=~/.ssh/id_rsa | |
remoteserver= # FILL IN, e.g [email protected] | |
localpath= # FILL IN without trailing slash, e.g ~/backups/server | |
usesudo= # FILL IN true or false | |
if [[ $usesudo == true ]]; then | |
rsyncargs=(-rlptzhu -e "ssh -p $sshport" --rsync-path="sudo rsync" --partial --delete-after --info=progress2) | |
else | |
rsyncargs=(-rlptzhu -e "ssh -p $sshport" --partial --delete-after --info=progress2) | |
fi | |
echo ":: Authenticating..." | |
ssh-add -l > /dev/null | |
if [[ $? != 0 ]]; then | |
ssh-add $sshcert | |
fi | |
backup() { | |
echo; echo ":: Backuping $1..." | |
mkdir -p $localpath/$1 | |
rsync "${rsyncargs[@]}" $remoteserver:$1/ $localpath/$1 | |
} | |
backup /etc | |
backup /home | |
backup /var/lib |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment