Rsync: order of transferred files and created directories

backuprsync

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.

Best Answer

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

Related Question