Aether/remote-backup

23 lines
781 B
Plaintext
Raw Normal View History

2016-09-21 21:43:35 -05:00
#!/bin/bash
if [ "$(whoami)" != "root" ]; then
echo Needs to be run as root.
exit 1;
fi
if (ping -c 4 "$1" | grep -c ' 0% packet loss,'); then
printf "Are you sure you want to back everything up to %s?\nIs the root password set and all storage mounted?\nDo you have time for this backup to complete?\nEnter YES in all capitals to continue..." "$1"
read answer
if [ "$answer" != "YES" ]; then
echo User did not confirm.
exit 1;
else
2016-12-13 19:58:03 -06:00
rsync -aAXv --delete --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / root@"$1":/mnt/
status="$?"
echo rsync exited with status $status
exit $status
2016-09-21 21:43:35 -05:00
fi
else
echo "Host is not responding in a timely fashion."
exit 1;
fi