New remote backup script
This commit is contained in:
21
remote-backup
Normal file
21
remote-backup
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/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
|
Reference in New Issue
Block a user