I have a working rsync call that takes a list of local directories to upload (simplified):

$ rsync --files-from=dirs_to_backup.txt --recursive ./ remote:

I now want to perform my own consistency checks on all local files, so I need the same file list that rsync used. There's a helpful option for that:


This option will cause the source files to be listed instead of transferred. This option is inferred if there is a single source arg and no destination specified, so its main uses are: (1) to turn a copy command that includes a destination arg into a file-listing command, or (2) to be able to specify more than one source arg (note: be sure to include the destination). Caution: keep in mind that a source arg with a wild-card is expanded by the shell into multiple args, so it is never safe to try to list such an arg without using this option. For example:

That sounds exactly what I need, but it fails when used together with --files-from

$ rsync --files-from=dirs_to_backup.txt --recursive ./

rsync  version 3.1.3  protocol version 31
Copyright (C) 1996-2018 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
    64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
    socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
    append, ACLs, no xattrs, iconv, symtimes, prealloc

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
rsync error: syntax or usage error (code 1) at options.c(2326) [client=3.1.3]

Explicitly adding --list-only in all positions didn't help either. The contents of dirs_to_backup.txt don't seem to matter either, even a non-existing file gives the same error. Removing --files-from works, but I want to keep this option.

Am I missing something or is this a bug? Are there any alternatives for listing only?


1 Answer 1


If you use --files-from=FILE then you cannot omit the destination directory. This holds even if you use --list-files.

# Works
rsync --times --files-from=FILE --list-only src/ dst/

# Fails
rsync --times --files-from=FILE --list-only src/

I would guess that the rationale here is that you already have a list of candidate files for transfer so you don't need rsync to repeat this back to you. Note that --list-only does not list the set of files that will be transferred; rather, it lists the candidate set of files that will be considered for transfer. You'll get a better view of the actual work to be done if you replace --list-only with --dry-run --itemize-changes --verbose:

rsync --dry-run -tiv --files-from=FILE src/ dst/
  • Thanks for the confirmation. Though I don't really buy into the rationale, because the given file list is just the first step in identifying candidate files. There's recursion, ignore lists, hidden files, permission issues... I'd like the list of candidate files after all that processing. And +1 for --itemize-changes, it's what I used in the end, coupled with a temp dir as destination.
    – BoppreH
    Apr 25, 2023 at 14:39
  • 1
    @BoppreH you could raise it as a bug. I've done that on occasion for other issues Apr 25, 2023 at 14:41
  • 1
    The functionality was there, but it was blocked by an overly zealous syntax check. I've created a PR.
    – BoppreH
    Apr 25, 2023 at 16:16

You must log in to answer this question.

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