5

I'm moving files with rsync and would like to be able to pick in destination folder to see what was transferred and what was not.

Here is a command I'm using:

rsync -azh --info=progress2 [email protected]:/home/backups/ /home/backups/

Problem is that rsync seems to be creating directories and transferring files quite randomly. So when I look into /home/backups/, I see many directories but most of them are empty.

Is it possible to instruct rsync to move down the directory tree and then come back up only when the branch is fully copied? I want it to do a depth-first search traversal.

4
  • You could try using --no-inc-recursive. Is there an actual issue with what you are seeing?
    – Kusalananda
    Commented Sep 6, 2017 at 14:00
  • The issues is that I'm seeing all (or most) directories as if their contents were already transferred, but they are not really (contents of directories is still to be transferred).
    – Nux
    Commented Sep 7, 2017 at 14:51
  • Is everything actually transferred in the end? It's not clear if you are talking about the state of things during or after copying.
    – Kusalananda
    Commented Sep 7, 2017 at 15:26
  • I'm talking about a state during copying. And a quite large transfer too (many backups in many directories).
    – Nux
    Commented Sep 8, 2017 at 12:28

1 Answer 1

3

Rsync actually does do a depth-first traversal, but it does so in two passes. In the first pass, it creates the directory structure, and then the second pass copies the files. I'm not 100% certain myself about why this is how it operates, but I am fairly certain that this is done per-source argument, so you could theoretically avoid this behavior partially by splitting your source directory to individual items (so if you have /some/path as your source, you can change it to /some/path/*/ to get rsync to only create the top level directories as it finishes the previous ones).

2
  • After reading more about star expansions I don't think it's safe to try star in that case. It would probably be interpreted locally. See: superuser.com/a/901188/87999
    – Nux
    Commented Sep 7, 2017 at 14:49
  • Unless you escape it (with \), it will be interpreted locally by the shell, and should result in rsync copying all directories (and files if you omit the trailing /) in that location to the destination. Commented Sep 7, 2017 at 15:21

You must log in to answer this question.

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