13

I'm trying to run rsync -a --files-from=~/.rsync_file_list ~/destination and it tells me: rsync error: syntax or usage error (code 1) at options.c(1652) [client=3.0.7]. Can anyone enlighten me as to what I'm doing wrong?

The file ~/.rsync_file_list just contains a list of file names prefaced with ~/, separated by newlines (though I've also tried listing them all on the same line, with the same result).

If I run rsync -a ~/file ~/file2 ~/file3 ~/destination it works just fine. So what am I missing about the --files-from option?

2
  • try sed "s#~/#/home/wolf/#g" -ie ~/.rsync_file_list – Andy Apr 12 '11 at 12:35
  • @Andy: Alas, same result. – Wolf Apr 12 '11 at 12:38
21

Okay, I found the problem.

  1. The file containing file names has to contain only file names; no paths, relative or otherwise;
  2. After specifying --files-from=FILE, rsync requires a source directory in which to find the files listed.

So the command should be rsync -a --files-from=~/.rsync_file_list $HOME/ /destination.

.rsync_file_list should read:

file 1
file 2
file 3
2
  • 3
    Correction: File names in the given file ARE relative to the source directory, but cannot be above it (no ../). Leading slashes will be ignored, so absolute paths don't work. – Wolf Apr 12 '11 at 22:28
  • I believe you can edit your own answer and add this very nice addition and relevant piece of info you found out later in the answer itself. – Vinícius M Jul 30 '18 at 17:01
0

Using the "~" may not work inside a "files-from" file unless rsync is smart enough to recognize and translate the "~" symbol.

When you specify a "~" as part of a command in your shell's command line, it is the shell itself that converts "~" to your home directory before passing the argument along to the program. So even though you type rsync -a ~/file, what rsync "sees" is actually the resolved path, or rsync -a /home/foo/file.

See Bash Tilde Expansion for more information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.