12

My weekly backup script contains a bunch of bash statements like these:

rsync -va /source_path/ /destination_path/

Now, this works great but the -v (verbose) option doesn't behave exactly like I want. What I want is that it should display only the changed files which are being copied, and not each and every folder it scans.

For example, if document1 and document2 folders are unchanged, but a file is changed in document3, then the display will be as follows:

document1/
document2/
document3/
document3/foo.txt

If I omit the -v option altogether, its totally silent and doesn't display anything at all. I want the output display but I'm only interested in the last line (foo.txt) which is the file being copied, not the dozens of folders which rsync scans such as document1, document2, etc.

Is there any way to do it?

2
  • That's already how rsync works. It's listing those directories because it thinks they're not in sync. Please run with the -i flag and include the output in your question.
    – BowlOfRed
    Mar 25, 2019 at 15:53
  • 1
    The directories might be getting sync'd just to update their timestamp. Use -i to see exactly why they being synced. You might try -c (checksum) or --size-only, or just filter them out with | egrep -v '/$'
    – Fitz
    Apr 2, 2019 at 3:25

1 Answer 1

10

Your description is already how rsync works. The only files it displays with -v are ones that it is either transferring or changing. So each time it runs, it sees there is some difference with the directories.

A common reason for this is that the source and destination are on different filesystems and the ownership or permissions can't be copied exactly, and each invocation is trying to do so.

To confirm this, run the rsync with -i (or --itemize-changes). This will display a code that shows the reason rsync has decided the file needs work. If its an ownership or something (and you decide you don't need this information), you can turn off the syncing of it with --no-owner or similar.

2
  • This worked for me, thanks @BowlOfRed. My source hard drive was using the EXT4 file system, and destination hard drive was using NFTS, so I kept getting those pointless directory listings described in the question above even though no files within those directories were being modified. Simply reformatting my destination drive to use EXT4 solved the problem. Jun 10, 2020 at 8:44
  • 5
    It would be better to use --omit-dir-times (-O), if it's the timestamps on the directories that are the issue. That way you don't really affect the way non-directories are synchronized.
    – Kusalananda
    Jul 16, 2021 at 7:36

You must log in to answer this question.

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