23 lines
781 B
Bash
23 lines
781 B
Bash
#!/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
|
|
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
|
|
fi
|
|
else
|
|
echo "Host is not responding in a timely fashion."
|
|
exit 1;
|
|
fi
|