Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
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
add comment

3 Answers

up vote 9 down vote accepted

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
share|improve this answer
    
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
add comment

Of course the filenames could containt paths: if you choose the full path name then the source directory is just "/".

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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