Rsync Sync's include and exclude to achieve precise synchronization

Source: Internet
Author: User
Tags rsync

Description

There is a directory/var/www/test/public/below, there are a lot of files, directories, but I just need to sync one of the 2 directories (JS,CSS). Using exclude to exclude other files, directory exclusion is certainly possible, but because other files, directories are very many, in the exclude exclusion obviously too time-consuming; or 2 line rsync direct sync/var/www/test/public/js,/var/www/test/ Public/css is also a can.
Like Rsync-nrv/var/www/feibo/fbtime_in/public/js/tmp/test/public, write 2 lines
But what if I just want 1 lines of rsync sync/var/www/test/public directory. Here, I need to first include-from specify the files or directories that need to be synchronized, exclude will/var/www/test/public all files, directories excluded

Realize:

1. Preparation of/root/shell/test.include documents

The code is as follows Copy Code

# Cat/root/shell/test.include
Js
Css

2.rsync sync specified file, directory

  code is as follows copy code

# RSYNC-NRV  --include-from=/root/shell/test.include--exclude=/*/var/www/test/public//tmp/test/public
-N,--dry-run                perform a trial run with no Changes made //dry run, light shows which file directories will be rsync and not run, for testing is very convenient
-R,--recursive              recurse into directories //verbose mode output
-V,--verbose                increase verbosity //subdirectories are processed in recursive mode


According to the internet, RSYNC-NRV--include-from=/root/shell/test.include--exclude=*/var/www/test/public//tmp/test/public, No files were found to be synchronized. Originally--exlucde=* is no good, need to specify--exclude=/*. The estimated meaning refers to all the file directories under the current directory/var/www/test/public/. --exclude=*/specifies all directories under the current directory/var/www/test/public/.
Note here that/var/www/test/public/needs to add the last/

Appendix:

Appendix 1 The results of the implementation can be seen only js,css directory is rsync

The code is as follows Copy Code

Sending incremental file list
Css/animate.css
Css/b
Css/global.css
Css/global.css_bak
js/a
Js/feibo.js
Js/feibo.js_bak
Js/global.js
Js/global.js_bak
Js/jquery-1.7.2.min.js
Js/jquery-1.8.0.min.js
Js/json2.min.js
Js/swfupload.js
js/swfupload.swf
js/swfupload_fp9.swf
Js/swfuploadhandlers.js
Js/wdatepicker/wdatepicker.js
Js/wdatepicker/calendar.js
Js/wdatepicker/lang/en.js
Js/wdatepicker/lang/zh-cn.js
Js/wdatepicker/lang/zh-tw.js
Js/wdatepicker/skin/wdatepicker.css
Js/wdatepicker/skin/datepicker.gif
Js/wdatepicker/skin/default/datepicker.css
Js/wdatepicker/skin/default/img.gif
Js/wdatepicker/skin/whygreen/bg.jpg
Js/wdatepicker/skin/whygreen/datepicker.css
Js/wdatepicker/skin/whygreen/img.gif
Js/zero/zeroclipboard.as
Js/zero/zeroclipboard.fla
Js/zero/zeroclipboard.js
js/zero/zeroclipboard.swf
Js/zero/zeroclipboard10.as
Js/zero/zeroclipboard10.fla
js/zero/zeroclipboard10.swf

Sent 1045 Bytes received 126 bytes 2342.00 Bytes/sec
Total size is 947225 speedup is 808.90 (DRY RUN)

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.