Saturday, June 28, 2008

Transfer Files Automatically

I had to backup the svn server and database (both running on Ubuntu) on our backup machine every day. It was painful enough that I decided to write a shell script to do it automatically. This might be the case for you as well.

Here is a Shell Script which backs up a folder on one machine by compressing and transferring it to another machine via ssh.

In order to back on a regular basis you may configure some fields in the shell script and place it in one of /etc/cron.* directories in Linux.

To configure the shell script you should set up these parameters:

FILE_NAME: File name to be backed up

TEMP_DIR: Directory for temporarily copying

DEFLATION: Whether to compress the file or not

EXTRACT: Whether to extract the file in destination

SRC_DIRs: Source Directory(s) to be backed up

DEST_DIR: Destination Directory

SRC_IP: Source machine IP Address use 127.0.0.1 for localhost

DEST_IP: Destination machine IP Address use 127.0.0.1 for localhost

SRC_USER: Source machine user

DEST_USER: Destination machine user

If the source and the destination machines were different, which usually are, the source machine should be able to connect to destination via ssh with no password. So you have to make them transparent to each other. this is a onetime process. For more convenience I've written a shell script named transparent-ssh which does the entire process.

Download the script and run this command on the source machine:

./transparent-ssh.sh [user] [destination-machine-ip]

It takes the remote machine username and IP address as arguments and installs your public key on the remote machine. The remote machine must accept password authentication or one of the other keys in your ssh-agent.

If you've already generated your public key once, just try the command with “-c” (copy only) parameter which only copies your public key to remote machine.

1 comment:

Anonymous said...

Who knows where to download XRumer 5.0 Palladium?
Help, please. All recommend this program to effectively advertise on the Internet, this is the best program!