Automated Backup Linux(Source) to Linux (Destination) :
Source IP - 126.96.36.199
Destination IP - 192.168.0.17
Here we need to backup data from 188.8.131.52 (/opt/mavb-proxy-recent/src) to 192.168.0.17 (/home/sriram)
1) First we need to automate the login process with out initializing the password.
- For that we use ssh-keygen
2) We need a Backup Script that can be run on the Backup Server (192.168.0.17) at the scheduled time.
- This script will connect using ssh, tar the specified directory and scp the directory to Backup Server and delete the tar file from the destination server.
- This can be added to cron job.
How To :
1) Creating SSH-Keygen in 192.168.0.17
#ssh-keygen -t rsa
Ente the Pass Phrase
2) Change the directory to cd /root/.ssh/ where the Public key is stored.
3) Copy your public keys to scp id_rsa.pub 184.108.40.206:/root/.ssh/authorized_keys2
4) Check if the server asks for password
# ssh 220.127.116.11
This should log in with out asking for password.
The script I run to take the backup in 192.168.0.17 (/home/sriram)
today=$(date +%Y%m%d-%H%M%S).tgz --- Variable Defined
ssh 18.104.22.168 "tar -cvf /opt/mavb-proxy-recent/$today /opt/mavb-proxy-recent/src " --- connects and tars(backup)
scp email@example.com:/opt/mavb-proxy-recent/$today . --- copyies the backup file to the backup server (192.168.0.17)
ssh 22.214.171.124 "rm -rf /opt/mavb-proxy-recent/$today" --- removes the backfile from the server(126.96.36.199)