Simple application and configuration of Rsync

Source: Internet
Author: User
Tags inotify

1. What is rsync? (Theory)
In short, the main feature is to achieve full and incremental data. local and remote data backup tools are also suitable for indows.
Official http://www.samba.org/ftp/rsync/rsync.html
Rsync supports rm deletion between local directories.
It synchronizes data based on the file size and modification time.
You can also back up data based on different permissions. You need to specify parameters.
2 features (theory)
Can be excluded
Maintain the time permission of the source directory and file and the attributes of the soft connection owner.
Can be encrypted with an ssh Channel
Can be used as a service to allow clients to connect
Supports anonymity and authentication
3 working method (theory)
Upload a local file similar to cpmingl
Use ssh
Daemon mode (important)
4. instance usage (Operation)
(1) Client Mode
Local Environment:
Upload File rsync/etc/hosts/opt
Upload directory rsync-avz/opt/mnt <= equivalent to cp-ap/opt/mnt
# Pay attention to the difference between/+ and not added after/opt. It is very important to add/just to pass the following file. If no value is added, your opt will pass, test it on your own if you cannot remember it.
Remote Environment:
Push (pass through): rsync-avz/etc/hosts-e "ssh-p 22000" root@64.78.172.119 :~
Pull (from remote host): rsync-avz root@64.78.172.119 :~ /Test.txt/etc/-e "ssh-p 22000"
# MEMORY command method: local directory --- remote ---- how-e "ssh-p22000"
(2) daemon mode
Configure the server rysnc
Vi/etc/rsyncd. conf
Uid = rsync
Gid = rsync
Use chroot = no
Max connections = 200
Timeout = 100
Pid file =/var/run/rsyncd. pid
Lock file =/var/run/rsync. lock
Log file =/var/log/rsyncd. log
[Oldboy]
Path =/oldboy/
Ignore errors
Read only = false
List = false
Hosts allow = 199.101.117.0/24
Hosts deny = 0.0.0.0/32
Auth users = rsync_backup
Secrets file =/etc/rsync. password
 
# If you edit or copy the encoding in windows to linux, you 'd better use this command to process Dos2unix/etc/rsyncd. conf.
Mkdir/oldboy
Useradd rsync-s/bin/nologin-M # create an account (which corresponds to the uid-gid of the configuration file. This account attribute cannot be logged on and has no directory)
Chown-R rsync. rsync/oldboy # (important)
Echo "rsync_backup: oldboy">/etc/rsync. password # rsync_backup is a virtual account. When the client connects, use this account and password oldboy.
Chmod 600/etc/rsyncd. conf # Set it to invisible to others because it contains a password.
Rsync -- daemon # start the process
 
# The above configuration is complete. The following is an operation command for managing rsync.
Lsof-I: 873 # Check whether the rsync service is enabled
Pkill rsync # Kill A Process
Killall rsync #
Ps-ef | grep rsync
 
# Client configuration: only two steps are required.
Echo "oldboy">/etc/rsync. password # This path has nothing to do with the server path. For the sake of standardization, the password must be the same as the service
Chmod 600/etc/rsync. password
 
# A production environment instance after the service and client are configured: the client backs up a website/var/ww/html
1. cd/var/www # Which directory to back up first goes to its previous directory
2. tar zcvf html _ $ (date + % F)./html
# Either of the two methods can be
(Module method)
(1)rsync-avzhtml_xxx.tar.gz rsync_backup@64.78.172.: oldboy -- password-file =/etc/rsync. password
(Resolution)
Rsync-avz html_xxx.tar.gz rsync: // rsync_backup@64.78.172.119/oldboy -- password-file =/etc/rsync. password
# It must be the directory/oldboy configured by the server. If it is changed to another directory, the push will fail, but the subdirectory can be/oldboy/test. Remember to authorize the chown rsync test subdirectory.
# Troubleshooting experience: if the connection fails, an error is returned. telnet port testing basically means that the Service port is not enabled. If Telnet succeeds, exit with ctrl +]
# If the error "no space" is reported, it indicates that the capacity is insufficient. If inode is full, use du-sh/* to check which directory is the largest and which directory is the most likely to be suspicious, go to the directory du-sh *
# The rsync. password permission on the server is root, which contains rsync_backup: oldboy

Rsync details: click here
Rsync: click here

Recommended reading:

Monitor host files and directories using inotifywait

Using inotify + rsync for Linux File batch update

Inotify-tools + rsync real-time file synchronization installation and configuration

Complete rsync synchronization Configuration

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.