2016-09-21 21:43:35 -05:00
#!/bin/bash
2023-07-15 22:34:00 -05:00
# File: HelloWorld.bash
#
# Description: This file exemplifies printing 'Hello world!' in bash.
#
# Package: AniNIX/HelloWorld
# Copyright: WTFPL
#
# Author: DarkFeather <ircs://aninix.net:6697/DarkFeather>
# Should only be done as root.
2016-09-21 21:43:35 -05:00
if [ " $( whoami) " != "root" ] ; then
echo Needs to be run as root.
exit 1;
fi
2023-07-15 22:34:00 -05:00
# Default the host to the Aether host in whatever domain this host lives in.
host = " $1 "
if [ -z " $host " ] ; then
host = Aether
fi
# Default the path to /
path = " $2 "
if [ -z " $path " ] ; then
path = '/'
fi
# Try to contract the host
if ( nmap --open -p 22 " $host " | grep -E '22/tcp\s+open' & >/dev/null) ; then
# Confirm with the user
printf "Are you sure you want to back everything up to %s?\n* Is the root password set and backup volume mounted on '/mnt'?\n* Do you have time for this backup to complete?\n* Does \`ssh-keyscan -D localhost\` on the server match this? `ssh-keyscan -D " $host " 2>/dev/null | grep 4\ 2`\nEnter YES in all capitals to continue..." " $host "
2016-09-21 21:43:35 -05:00
read answer
if [ " $answer " != "YES" ] ; then
echo User did not confirm.
exit 1;
else
2023-07-15 22:34:00 -05:00
rsync -aAXv --delete --exclude={ "/dev/*" ,"/proc/*" ,"/sys/*" ,"/tmp/*" ,"/run/*" ,"/mnt/*" ,"/media/*" ,"/lost+found" } " $path " root@" $host " :/mnt" $path "
2016-12-13 19:58:03 -06:00
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