New remote backup script
This commit is contained in:
parent
751925085e
commit
d7d5eb346c
18
Makefile
18
Makefile
@ -1,6 +1,10 @@
|
|||||||
SHELL := /bin/bash
|
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.
|
@echo You must specify client or server in a call to make.
|
||||||
|
|
||||||
client: user aether.bash
|
client: user aether.bash
|
||||||
@ -15,7 +19,7 @@ client: user aether.bash
|
|||||||
touch /var/log/aether.log
|
touch /var/log/aether.log
|
||||||
chown aether:aether /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
|
bash ./aether-gen.bash
|
||||||
cp ./aether.pub /home/aether/.ssh/authorized_keys
|
cp ./aether.pub /home/aether/.ssh/authorized_keys
|
||||||
chmod 0600 /home/aether/.ssh/authorized_keys
|
chmod 0600 /home/aether/.ssh/authorized_keys
|
||||||
@ -44,3 +48,13 @@ node-command:
|
|||||||
|
|
||||||
keys:
|
keys:
|
||||||
ssh-keygen -t rsa -P "" -f aether
|
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 .
|
||||||
|
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
|
Loading…
Reference in New Issue
Block a user