22 lines
742 B
Bash
22 lines
742 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 --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / root@"$1":/mnt/
|
|
echo rsync exited with status $?
|
|
exit $?
|
|
fi
|
|
else
|
|
echo "Host is not responding in a timely fashion."
|
|
exit 1;
|
|
fi
|