2

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 root@192.168.0.123:/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.

  • You could try using --no-inc-recursive. Is there an actual issue with what you are seeing? – Kusalananda Sep 6 '17 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 Sep 7 '17 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 Sep 7 '17 at 15:26
  • I'm talking about a state during copying. And a quite large transfer too (many backups in many directories). – Nux Sep 8 '17 at 12:28
1

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).

  • 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 Sep 7 '17 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. – Austin Hemmelgarn Sep 7 '17 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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