-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrestore.sh
38 lines (29 loc) · 972 Bytes
/
restore.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
apt-get install pv pixz
# Get hostname and modify it as per rules (lowercase and replace - with _)
folder_name=$(hostname | tr '[:upper:]' '[:lower:]' | tr '-' '_')
systemctl stop docker.socket
systemctl stop docker
systemctl stop runpod
# Generate SSH key and copy it to remote server
echo -e "\nGenerating SSH key and copying to server..."
ssh-keygen -f ~/.ssh/id_rsa -q -N ""
ssh-copy-id root@192.168.47.99
# Changing directory to root
cd /
# Downloading the tar file from the server
echo -e "\nRetrieving the tar file from server..."
ssh root@192.168.47.100 "cat /mnt/user/backup/$folder_name/docker.tar.pixz" | pv | pixz -d | tar x
# Unmask services
echo -e "\nUnmasking services..."
systemctl unmask docker.socket
systemctl unmask docker
systemctl unmask runpod
# Enable services
echo -e "\nEnabling services..."
systemctl enable docker.socket
systemctl enable docker
systemctl enable runpod
# Reboot the system
echo -e "\nRebooting..."
reboot