Friday, December 03, 2004

Automate Backup in Linux

Automated Backup Linux(Source) to Linux (Destination) :

Source IP -
Destination IP -


Here we need to backup data from (/opt/mavb-proxy-recent/src) to (/home/sriram)

Steps :

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 ( 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

#ssh-keygen -t rsa

Ente the Pass Phrase
eg pass

2) Change the directory to cd /root/.ssh/ where the Public key is stored.

Copy your public keys to scp

4) Check if the server asks for password

# ssh

This should log in with out asking for password.

The script I run to take the backup in (/home/sriram)

today=$(date +%Y%m%d-%H%M%S).tgz --- Variable Defined
ssh "tar -cvf /opt/mavb-proxy-recent/$today /opt/mavb-proxy-recent/src " --- connects and tars(backup)
scp root@$today . --- copyies the backup file to the backup server (
ssh "rm -rf /opt/mavb-proxy-recent/$today" --- removes the backfile from the server(

No comments: