Linux timed automatic offsite backup

Source: Internet
Author: User
Tags rsync

Purpose: Copy files on a server (192.168.0.23) to B Server (192.168.0.25) on a daily basis and do not replicate if they already exist.

Ideas:

    1. First, the server time is unified to avoid any inexplicable errors or management confusion. With NTP

    2. Due to cross-server replication, the issue of automatic password entry is involved. Need to be addressed.

    3. Using SCP replication will overwrite existing files and add useless work. Use Rsync instead.

    4. Crontab is required for automatic execution of commands on a timed basis.


Steps to resolve:

    1. Resolve time synchronization issues

      Synchronize the time of the internal NTP server with the Ntpdate 192.168.0.253. In order to synchronize the time of the automatic execution later, in/etc/ntp.conf, add the NTP server:

      Vi/etc/ntp.conf

      Server 192.168.0.253

      : X

    2. Solve the problem of automatic password entry

      Reference URL: http://blog.sina.com.cn/s/blog_8ad7d4ca01014lft.htm

      There are two ways, one is to use expect, need to install. One is to use the key file. The second key file is used here.

      Execute the following command on a server to generate the pairing key:

      SSH-KEYGEN-T RSA

      When prompted to enter the default, the public key is stored in the user directory. SSH directory, such as root:/root/.ssh/id_rsa.pub

      Copy the Id_rsa.pub file from the. SSH directory to the ~/.ssh/directory of B and rename it to Authorized_keys.

    3. Copy with rsync:

      -avzu/root/.ssh/id_rsa 192.168.0.25:/backup/ncbackup

    4. Write this command in the cron service:

      Crontab-e

      XX * * * */usr/bin/rsync-avzu/root/.ssh/id_rsa 192.168.0.25:/backup/ncbackup

      Reference: http://www.blogjava.net/decode360/archive/2009/09/18/287743.html



Linux scheduled automatic offsite backup

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.