因此,我想将一堆文件从我的 Mac 同步到外部驱动器,并尝试这样做:
$ rsync -vv --files-from=backup.txt /Volumes/Seagate\ Expansion\ Drive/2022-12-27-imac-backup/
rsync version 2.6.9 protocol version 29
Copyright (C) 1996-2006 by Andrew Tridgell, Wayne Davison, and others.
<http://rsync.samba.org/>
Capabilities: 64-bit files, socketpairs, hard links, symlinks, batchfiles,
inplace, IPv6, 64-bit system inums, 64-bit internal inums
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
....
....
(snip)
....
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
rsync error: syntax or usage error (code 1) at /AppleInternal/Library/BuildRoots/aaefcfd1-5c95-11ed-8734-2e32217d8374/Library/Caches/com.apple.xbs/Sources/rsync/rsync/options.c(1436) [client=2.6.9]
所以它没有指出哪里出错了,但确实出了问题。我猜文件格式错了?但情况也没那么奇怪:
$ cat backup.txt
/Users/carlerik/Downloads/Paragon-31091-PEU_MacInstallUnlock-15.10.485.dmg
/Users/carlerik/Documents/Øvelser.ptflow
/Users/carlerik/Pictures/syncdir/2019
/Users/carlerik/Pictures/dump
/Users/carlerik/Pictures/dronebilder*
/Users/carlerik/Pictures/profilbilde
/Users/carlerik/sohf_next-2022_10_18_11_09_03-dump.sql
/Users/carlerik/develop_k8s-2022_10_25_10_56_35-dump.sql
寻找例子并不是很有成效,因为没有人列出从文件。
$ rsync --version
rsync version 2.6.9 protocol version 29
答案1
您需要指定源目录;它从“源”文件 (backup.txt) 获得的路径被视为相对于该源的路径。看起来您在 backup.txt 文件中有绝对路径,因此您需要指定/
为源目录:
rsync -vv --files-from=backup.txt / /Volumes/Seagate\ Expansion\ Drive/2022-12-27-imac-backup/
# ^ this is the source directory argument
您还可以指定/Users/carlerik
为源目录,并修改 backup.txt 以仅指定其中的路径(例如Documents/Øvelser.ptflow
而不是/Users/carlerik/Documents/Øvelser.ptflow
)。
请注意,/
文件中路径开头的 将被忽略。从手册页中:
从 FILE 读取的文件名都与源目录相关 - 删除所有前导斜杠,并且不允许“..”引用高于源目录。例如,执行以下命令:
rsync -a --files-from=/tmp/foo /usr remote:/backup
如果 /tmp/foo 包含字符串“bin”(甚至“/bin”),则 /usr/bin 目录将在远程主机上创建为 /backup/bin。