Rsync synchronization Specifies a multiple-file directory method

Source: Internet
Author: User
Tags rsync

Description
You can only exclude upload files/directories using Rsync-av--exclude=upload/home/mysql/backup/home/mysql/backup2/. However, if you want to exclude multiple files/directories, you need to create a new exclude.list and then Rsync-av--exclude-from= "exclude.list" to specify files/directories that do not need to be synchronized

Realize:

The code is as follows Copy Code

# Rsync-av--exclude-from=/root/exclude.list/home/mysql/backup/home/mysql/backup2/
Copy the/home/mysql/backup directory to the/home/mysql/backup2 directory,/root/exclude.list the specified file is not copied.


Note Exclude.list fill in the File/directory to exclude, one line, directly to write the file name.
So if you want to rule out a,b.1,b.2,tmp/g, then exclude.list should write

The code is as follows Copy Code

A
b.*
Tmp/g

Instead of filling in the full URL below. Otherwise, this will still be synchronized a,b.1,b.2,tmp/g

The code is as follows Copy Code

/home/mysql/backup/a
/home/mysql/backup/b.*
/home/mysql/backup/tmp/g

Of course, the following writing is also synchronized a,b.1,b.2,tmp/g file, there are problems

The code is as follows Copy Code

./home/mysql/backup/a
./home/mysql/backup/b.*
./home/mysql/backup/tmp/g


Appendix:

  code is as follows copy code
--exclude= Pattern exclude files Matching pattern
--exclude-from=file read exclude patterns from FILE
--include=pattern don ' t Exclude files matching pattern
--include-from=file read include patterns from FILE

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.