One, usage example 1, incremental backup local file#rsync-av ebook/tmp///Note: It is best not to have the file name:#rsync-AVZRTOPGL--PROGRESS/SRC/DST2. Local and Remote directory synchronization#rsync-AUV--delete Program doc/media/cbdisk/project///sync to USB drive#rsync-AU
group IDs of numbers to user and group names--timeout=time IP timeout time in seconds-I,--ignore-times not skip those files that have the same time and length--size-only when deciding whether to back up a file, just look at the file size without considering the file time--modify-window=num the time stamp window that determines whether a file is in the same time, default is 0-t--temp-dir=dir create temporary files in dir--compare-dest=dir also compares files in DIR to determine whether a backup
, so that you can directly call the rsync command under the command line.3. Open the command line window and execute the command
(The IP address of my server is 192.168.31.23)
Upload Command:
Rsync-av -- progress -- remove-source-files -- exclude-from =/cygdrive/d/upload. list/cygdrive/d/Message/root@192.168.31.213: Message -- password-file =/cygdrive/d/pass/rsyn
RSNC Remote SyncInstallation package: rsync-3.0.6-4.el5_7.1.x86_64.rpmRPM-IVH rsync-3.0.6-4.el5_7.1.x86_64.rpmThe local mode only needs to install Rsync:Rsync-av/secbox/backup Backup to LocalRsync-a/backup View a list of local filesRemote Shell mode: Serves as a server for disaster recovery: Service xinetd StartOn client operations:Rsync-ava/secbox 192.168.1.12::backup Backup to remoteRsync-a 192.168.1.12::
in Windows, we need to download the cwRsync tool, which is an rsync for windows version.
The directory structure after the download and installation is similar to the following:
Now we can run rsync in Windows. For example, use the following command to connect to the server and start backing up directories and files:
Rsync-vzrtopg --
-- Modify-window = NUM determines whether the timestamp window of the file is used at the same time. The default value is 0.-T -- temp-dir = DIR create a temporary file in DIR-- Compare-dest = DIR: compare the files in DIR to determine whether to back up data.-P is equivalent to -- partial-- Progress displays the backup process-Z, -- compress compresses backup files during transmission-- Exclude = PATTERN specifies to exclude file modes that do not ne
changed files (for new files) or changes to the file (for the original file).Rsync does not have a speed advantage when it is first copied, and it is not as fast as tar, so when the amount of data is large you might consider first copying with tar before using rsync for data synchronization.Today you need to back up a directory file of more than 50 g to the backup machine, because the SCP does not support
authorized to access the module and needs to correspond to the/etc/rsyncd.secrets.Remote sync:
The code is as follows
Copy Code
sudo rsync-arlhptgzqh--delete--delay-updates--progress fhp@serverip::share--password-file=/etc/rsync_password/ Media/server/server1/home/etc/rsync_password
You just need to fill in the code.
Unfortunately,
--timeout=time IP timeout time in seconds-I,--ignore-times not skip those files that have the same time and length--size-only when deciding whether to back up a file, just look at the file size without considering the file time--modify-window=num the time stamp window that determines whether a file is in the same time, default is 0-t--temp-dir=dir create temporary files in dir--compare-dest=dir also compares files in DIR to determine whether a backup is required-P equals to--partial--
? Daemon
Rsync starts at Port 873.
Ii. Client Configuration
Edit a rsyncd. secrets password under/etc to store the file.
Run the following command:
Rsync-vzurtopg -- progress -- delete root@192.168.100.150: rsyncd/home/test -- password-file =/etc/rsync. secret
Parameter v indicates a detailed prompt
Z indicates Compr
permissionsIf this step is not completed, the following message is displayed:Password file must not be other-accessibleContinuing without password filePassword:
2. synchronous connection test[Root @ mail pub] # rsync-vzrtopg -- progress -- delete -- password-file =/etc/rsyncd. secrets test@192.168.0.61: test/var/www/example_com/dl01/pub/Refreshing incremental file list./Test.txt0 100% 0.00kB/s 0:00:00 (xfe
= rsync filesread only = nolist = yesauth users = chicken00secrets file =/ etc /. rsyncd. secrets
# Set the user name and password. The user name is the same as that specified in the configuration file (auth users)
$ Echo "chicken00: chicken00">/Etc/. rsyncd. secrets# File permissions must be set to 600$ Chmod 600/etc/. rsyncd. secrets
3. Start
# Set to boot$ Chkconfig rsync on# Viewing startup$ Chkcon
passwordSet this file to 600 permissions. 1 Chmod 600 rsyncd_515aaa.scrt After configuring the client, you can perform the rsync synchronization test.Step 6:Allow the rsync client to automatically synchronize data with the serverThe crontab command is used to execute tasks in a scheduled manner.Crontab [-u username] [-l |-e |-r] options and parameters:-u: Only r
--EXCLUDE=PATTERN Specifies to exclude file modes that do not require transfer
--INCLUDE=PATTERN Specifies the file mode that is not excluded and needs to be transferred
--exclude-from=file exclude files in the specified mode in file
--include-from=file does not exclude files that match the file-specified pattern
--version Print version Information
--address bound to a specific address
--CONFIG=FILE specifies a different profile and does not use the default rsyncd.conf file
--PORT=PORT Specifie
files, enter the account password account that exists in the Linux system: password Five modify Etc/xinetd/rsync file to change disable = yes to disable = No six start the Rsync service based on the XINETD process #/etc/init.d/xinetd start Seven Windows machine installed cwrsync eight open 873 ports on Linux (the port that Rsync uses by default) Nine open cmd
*.rpm *.deb *.iso *.bz2
Revise look personal situation, general modification Path=/home/soft/rsync for own directory
Create a new file under/etc/after the change is finished Rsyncd.pass
#vi/etc/rsyncd.pass
Backup:backup
: Wq
Modify Rsyncd.pass Permissions
#chmod 600/etc/rsyncd.pass
We can start rsync now.
#rsync--daemon
After successful startup, you can use lso
username, this example is backup
Secrets file =/etc/backup.pass #认证用户的密码文件
3, edit the server password file/etc/backup.pass
Vi/etc/backup.pass
backup:123456
4, then set permissions chmod 400/etc/backup.pass
Client Configuration
1. Edit the password file at Rsync connection/etc/rsync_client.pass
Vi/etc/rsync_client.pass
123456 # You only need to configure the password to use when connecting, you must be the same as the password defined on ser
-only, recommended as 600, only valid after setting auth usersHosts allow = 192.168.0.0/255.255.255.0?? #设置哪些主机可以同步数据, use spaces between multiple IP and network segmentsHosts deny=*??? #除了hosts the host defined by allow, deny all otherList = False??? #客户端请求显示模块列表时, if the module name is displayed, the default is True?Firewall security Settings#firewall-cmd--permanent--add-port=873/tcp??? #添加防火墙规则, allow 873-port data access#setenforce 0?Installing the HTTP Service # yum Install Httpd–y Create a
-- daemon
Verify that the startup is successful:
Netstat-na | grep 873
4. Configure rsync
Simple configuration: edit the/etc/rsyncd. conf file as follows:
# Global configuration
Secrets file =/etc/rsyncd. secrets name and location of the authenticated user name and password file
Motd file =/etc/rsyncd. motd welcome information file name and storage location (this file does not exist, you can add it yourself)
Read only = yes
List = yes
Uid =
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.