Tips : FreeBSD 和 Mac OS X 提供一个类似于 inotify 的 kqueue,在 FreeBSD 机器上输入 man 2 kqueue 获取更多信息,本文基于 Ubuntu Desktop version 8.04.1(即 Hardy),它运行在 Mac OS X version 10.5 Leopard 的 Parallels Desktop version 3.0。
rsync version 3.0.8 protocol version 30 Copyright (C) 1996-2011 by Andrew Tridgell, Wayne Davison, and others. Web site: http://rsync.samba.org/ Capabilities: 64-bit files, 64-bit inums, 32-bit timestamps, 64-bit long ints, socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace, append, ACLs, no xattrs, iconv, symtimes
rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. See the GNU General Public Licence for details.
rsync is a file transfer program capable of efficient remote update via a fast differencing algorithm.
Usage: rsync [OPTION]... SRC [SRC]... DEST or rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST or rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST or rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DEST or rsync [OPTION]... [USER@]HOST:SRC [DEST] or rsync [OPTION]... [USER@]HOST::SRC [DEST] or rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST] The ':' usages connect via remote shell, while'::' & 'rsync://' usages connect to an rsync daemon, and require SRC or DEST to start with a module name.
Options -v, --verbose increase verbosity -q, --quiet suppress non-error messages --no-motd suppress daemon-mode MOTD (see manpage caveat) -c, --checksum skip based on checksum, not mod-time & size -a, --archive archive mode; equals -rlptgoD (no -H,-A,-X) --no-OPTION turn off an implied OPTION (e.g. --no-D) -r, --recursive recurse into directories -R, --relative use relative path names --no-implied-dirs don't send implied dirs with --relative -b, --backup make backups (see --suffix & --backup-dir) --backup-dir=DIR make backups into hierarchy based in DIR --suffix=SUFFIX set backup suffix (default ~ w/o --backup-dir) -u, --update skip files that are newer on the receiver --inplace update destination files in-place (SEE MAN PAGE) --append append data onto shorter files --append-verify like --append, but with old data in file checksum -d, --dirs transfer directories without recursing -l, --links copy symlinks as symlinks -L, --copy-links transform symlink into referent file/dir --copy-unsafe-links only "unsafe" symlinks are transformed --safe-links ignore symlinks that point outside the source tree -k, --copy-dirlinks transform symlink to a dir into referent dir -K, --keep-dirlinks treat symlinked dir on receiver as dir -H, --hard-links preserve hard links -p, --perms preserve permissions -E, --executability preserve the file's executability --chmod=CHMOD affect file and/or directory permissions -A, --acls preserve ACLs (implies --perms) -o, --owner preserve owner (super-user only) -g, --group preserve group --devices preserve device files (super-user only) --specials preserve special files -D same as --devices --specials -t, --times preserve modification times -O, --omit-dir-times omit directories from --times --super receiver attempts super-user activities -S, --sparse handle sparse files efficiently -n, --dry-run perform a trial run with no changes made -W, --whole-file copy files whole (without delta-xfer algorithm) -x, --one-file-system don't cross filesystem boundaries -B, --block-size=SIZE force a fixed checksum block-size -e, --rsh=COMMAND specify the remote shell to use --rsync-path=PROGRAM specify the rsync to run on the remote machine --existing skip creating new files on receiver --ignore-existing skip updating files that already exist on receiver --remove-source-files sender removes synchronized files (non-dirs) --del an alias for --delete-during --delete delete extraneous files from destination dirs --delete-before receiver deletes before transfer, not during --delete-during receiver deletes during transfer (default) --delete-delay find deletions during, delete after --delete-after receiver deletes after transfer, not during --delete-excluded also delete excluded files from destination dirs --ignore-errors delete even if there are I/O errors --force force deletion of directories even if not empty --max-delete=NUM don't delete more than NUM files --max-size=SIZE don't transfer any file larger than SIZE --min-size=SIZE don't transfer any file smaller than SIZE --partial keep partially transferred files --partial-dir=DIR put a partially transferred file into DIR --delay-updates put all updated files into place at transfer's end -m, --prune-empty-dirs prune empty directory chains from the file-list --numeric-ids don't map uid/gid values by user/group name --timeout=SECONDS set I/O timeout in seconds --contimeout=SECONDS set daemon connection timeout in seconds -I, --ignore-times don't skip files that match in size and mod-time --size-only skip files that match in size --modify-window=NUM compare mod-times with reduced accuracy -T, --temp-dir=DIR create temporary files in directory DIR -y, --fuzzy find similar file for basis if no dest file --compare-dest=DIR also compare destination files relative to DIR --copy-dest=DIR ... and include copies of unchanged files --link-dest=DIR hardlink to files in DIR when unchanged -z, --compress compress file data during the transfer --compress-level=NUM explicitly set compression level --skip-compress=LIST skip compressing files with a suffix in LIST -C, --cvs-exclude auto-ignore files the same way CVS does -f, --filter=RULE add a file-filtering RULE -F same as --filter='dir-merge /.rsync-filter' repeated: --filter='- .rsync-filter' --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 --files-from=FILE read list of source-file names from FILE -0, --from0 all *-from/filter files are delimited by 0s -s, --protect-args no space-splitting; only wildcard special-chars --address=ADDRESS bind address for outgoing socket to daemon --port=PORT specify double-colon alternate port number --sockopts=OPTIONS specify custom TCP options --blocking-io use blocking I/O for the remote shell --stats give some file-transfer stats -8, --8-bit-output leave high-bit chars unescaped in output -h, --human-readable output numbers in a human-readable format --progress show progress during transfer -P same as --partial --progress -i, --itemize-changes output a change-summary for all updates --out-format=FORMAT output updates using the specified FORMAT --log-file=FILE log what we're doing to the specified FILE --log-file-format=FMT log updates using the specified FMT --password-file=FILE read daemon-access password from FILE --list-only list the files instead of copying them --bwlimit=KBPS limit I/O bandwidth; KBytes per second --stop-at=y-m-dTh:m Stop rsync at year-month-dayThour:minute --time-limit=MINS Stop rsync after MINS minutes have elapsed --write-batch=FILE write a batched update to FILE --only-write-batch=FILE like --write-batch but w/o updating destination --read-batch=FILE read a batched update from FILE --protocol=NUM force an older protocol version to be used --iconv=CONVERT_SPEC request charset conversion of filenames --tr=BAD/GOOD transliterate filenames -4, --ipv4 prefer IPv4 -6, --ipv6 prefer IPv6 --version print version number (-h) --help show this help (-h works with no other options) Use "rsync --daemon --help" to see the daemon-mode command-line options. Please see the rsync(1) and rsyncd.conf(5) man pages for full documentation. See http://rsync.samba.org/ for updates, bug reports, and answers
# Options - 参数说明 @<file> 从监视中排除指定的文件。 --exclude <pattern> 排除与扩展正则表达式<pattern>匹配的文件上的所有事件。 --excludei <pattern> 不区分大小写 -m, --monitor inotifywait的默认动作是在监控至指定文件的特定事件发生一次后就退出了,而使用此选项则可实现持续性的监控 -d,--daemon 与--monitor相同,只是在后台运行,将事件记录到--outfile.Implies--syslog指定的文件中。 -r, --recursive 递归监控指定目录下的所有文件,包括新建的文件或子目录;如果要监控的目录中文件数量巨大,则通常需要修改`/proc/sys/fs/inotify/max_users_watchs`内核参数因为其默认值为8192; --fromfile <file> 从<file>或-for stdin读取要监视的文件。 -o|--outfile <file> 将事件打印到<file>而不是标准输出。 -s|--syslog 将错误发送到syslog而不是stderr。 -q, --quit 即静默模式 -qq Print nothing (not even events). -c|--csv Print events in CSV format. -e, --event :指定要监控的特定事件,默认是监控所有的事件;此处包括 access(访问), modify(修改), attrib(属性), close_write, close_nowirte, close(关闭), open(打开), moved_to, moved_from, move(移动), create(创建), delete(删除), delete_selt等(前面已有详细说明) * access file or directory contents were read * modify file or directory contents were written * attrib file or directory attributes changed * close_write file or directory closed, after being opened in writable mode * close_nowrite file or directory closed, after being opened inread-only mode * close file or directory closed, regardless of read/write mode * open file or directory opened * moved_to file or directory moved to watched directory * moved_from file or directory moved from watched directory * move file or directory moved to or from watched directory * create file or directory created within watched directory * delete file or directory deleted within watched directory * delete_self file or directory was deleted --timefmt :当在--format选项中使用%T时,--timefrt选项则可以用来指定自定义的符合strftime规范的时间格式,此时间格式可用的格式符可以通过strftime的手册页获取;常用的参数是 '%d/%m/%y %H:%M'(25/06/17/13:11); --format :自定义inotifywait的输出格式,如--format '%T %w %f';常用的格式符如下: * %T:使用--timefmt选项中自定义的时间格式; * %w:显示被监控文件的文件名; * %f:如果发生某事件的对象是目录,则显示被监控目录的名字;默认显示为空串; -t|--timeout <seconds> 收听单个事件时,请在等待事件<seconds>秒。如果<seconds>为0,inotifywait将永远不会超时。
bash$ rsync -a 144.16.251.213::test test Password: @ERROR: auth failed on module test I dont understand this. Can somebody explain as to how to acomplish this. All suggestions are welcome. 应该是没有以你的用户名登陆导致的问题,试试rsync -a max@144.16.251.213::test test
Q:当rsync遇到ssh不是标准端口时 If ssh port is not 22, how does rsync specify this in command line? A:rsync要借助ssh来运行,那么当ssh的端口不是默认的22怎么办? 把选项中的-e ssh 换成 -e ssh -p 12345 这里12345是ssh的端口号
问题4.在client上遇到问题报could not open password file "/etc/rsync.pas": No such file or directory (2)错误
错误信息:
1 2 3 4 5
$ rsync -auzv --progress --password-file=/etc/rsync.pas root@192.168.133.128::backup /home/ rsync: could not open password file "/etc/rsync.pas": No such file or directory (2) Password: @ERROR: auth failed on module backup rsync error: error starting client-server protocol (code 5) at main.c(1506) [Receiver=3.0.7]
问题5.在client上遇到问题报rsync: write failed on "/home/backup2010/": No space left on device (28)错误
错误信息:
1 2 3 4 5 6
rsync: write failed on "/home/backup2010/": No space left on device (28) rsync: recv_generator: mkdir "/home/backup2010/" failed: No space left on device (28) *** Skipping any contents from this failed directory *** rsync error: error in file IO (code 11) at receiver.c(302) [receiver=3.0.7] rsync: connection unexpectedly closed (2721 bytes received so far) [generator] rsync error: error in rsync protocol data stream (code 12) at io.c(601) [generator=3.0.7]
eceiving incremental file list skipping non-regular file “vendor/bin/doctrine” skipping non-regular file “vendor/bin/doctrine.php”\ sent 1990 bytes received 489209 bytes 327466.00 bytes/sec total size is 182515746 speedup is 371.57
错误原因: source源文件有软链接。
解决方法: 修改为 rsync -va 其中 -a == -rlptgoD (no -H,-A,-X) 或者 rsync -rvltOD 也可以。
问题7.报@ERROR: module is read only错误。
错误信息:
1 2 3 4 5
sending incremental file list ERROR: module is read only rsync error: syntax or usage error (code 1) at main.c(866) [receiver=3.0.6] rsync: read error: Connection reset by peer (104) rsync error: error in rsync protocol data stream (code 12) at io.c(759) [sender=3.0.6]
错误原因: Source源服务器端权限设置read为only只读权限。
解决方法: read only = false
问题8.报password file must not be other-accessible错误。
错误信息:
1 2
password file must not be other-accessible continuing without password file
错误原因: 因为 rsyncd.pwd rsyncd.secrets 的权限不对。
解决办法: 设置上述文件权限为600。
1
chmod 600 rsyncd.pwd
问题9.报rsync: failed to connect No route to host错误。
错误信息: rsync: failed to connect to 192.168.1.10: No route to host (113) rsync error: error in socket IO (code 10) at clientserver.c(104) [receiver=3.0.6]
1 2 3 4 5
rsync: failed to connect to 10.10.10.170: Connection refused (111) rsync: failed to connect to 96.44.169.178 (*inet_ntop failed*): Connection timed out (116) 1 [main] rsync 3468 exception::handle: Exception: STATUS_ACCESS_VIOLATION 740 [main] rsync 3468 open_stackdumpfile: Dumping stack trace to rsync.exe.s
解决办法: 在服务器端的 /etc/rsyncd.conf 中修改入键值 use chroot = yes。
问题13.报rsync: read error: Connection reset by peer (104)
错误信息: rsync: read error: Connection reset by peer (104) rsync error: error in rsync protocol data stream (code 12) at io.c(794) [receiver=3.0.6]
1 2 3 4 5
receiving incremental file list rsync: read error: Connection reset by peer (104) rsync error: error in rsync protocol data stream (code 12) at io.c(769) [receiver=3.0.8] rsync: connection unexpectedly closed (60 bytes received so far) [generator] rsync error: error in rsync protocol data stream (code 12) at io.c(610) [generator=3.0.8]
问题原因:
磁盘挂载是用异步的(async)然后检查了/etc/fstab ,去掉async参数
我在服务器上查看日志看到有这么一行:rsync: unable to open configuration file “/etc/rsyncd.conf”: No such file or directory于是我:ln -s /etc/rsyncd/rsyncd.conf /etc/rsyncd.conf
问题15.报rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(544)错误。
错误信息:
1 2
rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(544) [receiver=3.0.5] rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(544) [generator=3.0.5]
--iconv=CONVERT_SPEC Rsync can convert filenames between character sets using this option. Using a CONVERT_SPEC of "." tells rsync to look up the default character-set via the locale setting. Alternately, you can fully specify what conversion to do by giving a local and a remote charset separated by a comma in the order --iconv=LOCAL,REMOTE, e.g. --iconv=utf8,iso88591. This order ensures that the option will stay the same whether you're pushing or pulling files. Finally, you can specify either --no-iconv or a CONVERT_SPEC of "-" to turn off any conversion. The default setting of this option is site-specific, and can also be affected via the RSYNC_ICONV environment variable.
问题18.在window上rsync同步数据报错:rsync error: some files/attrs were not transferred (see previous errors) (code 2 3) at main.c(1052) [sender=3.0.8]
方式1.请访问本博主的B站【WeiyiGeek】首页关注UP主, 将自动随机获取解锁验证码。
Method 2.Please visit 【My Twitter】. There is an article verification code in the homepage.
方式3.扫一扫下方二维码,关注本站官方公众号
回复:验证码
将获取解锁(有效期7天)本站所有技术文章哟!