New remote backup script

This commit is contained in:
DarkFeather 2016-09-21 21:43:35 -05:00
parent 751925085e
commit d7d5eb346c
3 changed files with 37 additions and 2 deletions

View File

@ -1,6 +1,10 @@
SHELL := /bin/bash
null:
compile:
pacman -S openssl gzip tar openssh
make keys
install:
@echo You must specify client or server in a call to make.
client: user aether.bash
@ -15,7 +19,7 @@ client: user aether.bash
touch /var/log/aether.log
chown aether:aether /var/log/aether.log
server: user aether-gen.bash aether.pub server-backup
server: scripts user ./aether-gen.bash ./aether.pub ./server-backup
bash ./aether-gen.bash
cp ./aether.pub /home/aether/.ssh/authorized_keys
chmod 0600 /home/aether/.ssh/authorized_keys
@ -44,3 +48,13 @@ node-command:
keys:
ssh-keygen -t rsa -P "" -f aether
scripts: ./server-backup ./remote-backup
cp ./server-backup /root/bin
chmod 0700 /root/bin/server-backup
cp ./remote-backup /root/bin
chmod 0700 /root/bin/remote-backup
reverse:
cp /root/bin/server-backup .
cp /root/bin/remote-backup .

View File

21
remote-backup Normal file
View 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