14

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, 2011 at 12:35
  • @Andy: Alas, same result.
    – Wolf
    Apr 12, 2011 at 12:38

2 Answers 2

24

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
3
  • 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, 2011 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. Jul 30, 2018 at 17:01
  • Thanks, I was missing the source folder, I thought it was implicitly the current one.
    – vault
    Sep 23, 2022 at 18:35
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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .