Tuesday, March 29, 2011

How to Automatically Backup Inter 2 Server Linux

How to Automatically Backup Inter 2 Server Linux

Using Linux as an operating system has many advantages. In addition to virus-resistant, many automated functions that can be done through scripts. For example, for backup or synchronization between two file-sharing server can be done with scp command (server copy) combined with cron to automate (scheduling).

Scp command requires the function ssh (secure shell) to be connected with a remote server. So ssh can simply fill in the connect without a password, do the following:

1. Create a private / public key on the local server
ssh-keygen-t rsa

2. Copy public key to the remote server
scp ~ / .ssh / id_rsa.pub remote_host:

3. Add the key to the remote server is trusted key

Login to the remote server. If you have not ever make a key at all, run ssh-keygen-t rsa to prepare a directory for the key.

Then add a new key made earlier to the file authorized_keys
cat ~ / id_rsa.pub>> ~ / .ssh / authorized_keys

Change the file-level access to the command:
chmod 644 ~ / .ssh / authorized_keys


4. Now you try to login to a remote server via ssh
ssh username @ remote_server

If the above steps correctly, you should get in without entering a password.

5. Create a script to copy files from remote servers
scp username @ remote_server: / remote_dir / local_dir

Save command into a file (eg: mybackup.sh) and change its file mode with chmod 755 mybackup.sh

Mybackup.sh file copy to the directory / etc / cron.daily to get running automatically every day.

No comments:

Post a Comment

 
THANK YOU FOR VISITING