Rsync exclusion file and folder Parameters

Source: Internet
Author: User

Rsync is a very good tool for synchronizing data between servers. It is better than ftp or other transmission software and is fast and stable, today I will introduce the rsync synchronization configuration to exclude files that we don't want to synchronize and not synchronize them.


Assume that the initial command is as follows:
Rsync-e 'ssh-p 30000 '-avl -- delete -- stats -- progress demo@123.45.67.890:/home/demo/backup/

I. exclude separate folders and files

To exclude the sources folder, we can add the '-- exclude' option:

-- Exclude 'Sources'

The command is as follows:
Rsync-e 'ssh-p 30000 '-avl -- delete -- stats -- progress -- exclude 'Sources' demo@123.45.67.890:/home/demo/backup/

To exclude the "database.txt" file in the "public_html" folder:

-- Exclude 'public _ html/database.txt'

The command is as follows:
Rsync-e 'ssh-p 30000 '-avl -- delete -- stats -- progress -- exclude 'Sources' -- exclude 'public _ html/database.txt 'demo@123.45.67.890:/home/demo/backup/

Ii. Use '-- exclude-from' to exclude Multiple folders and files

Create a file:
/Home/backup/exclude.txt

Define the folders and files to be excluded
Sources
Public_html/database .*
Downloads/test /*

Instructions:
-- Exclude-from '/home/backup/exclude.txt'

The final command is as follows:
Rsync-e 'ssh-p 30000 '-avl -- delete -- stats -- progress -- exclude-from'/home/backup/exclude.txt 'demo@123.45.67.890:/home/demo/backup/


Other common parameters of Rsync

1
-Z-compress file data during the transfer
-- Compress-level = NUM explicitly set compression level
-- Skip-compress = LIST skip compressing files with suffix in LIST
For compressed transmission, if the network bandwidth is not enough, it should be compressed for later transmission, which consumes Of course machine resources. However, if the number of files transmitted over the Intranet is not large, this parameter is unnecessary.
2
-- Password-file = FILE

As mentioned above, this parameter can be used only when the remote machine is an rsync server.
If you think that the FILE is written with the ssh login password, it is a big mistake. Many people have made this mistake.
3
-Stats: Adds a little more output regarding the file transfer status.
4
-Progress: shows the progress of each file transfer. Can be useful to know if you have large files being backup up.

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.