Disk usage issue with rsync and -link-dest

I have a problem with rsync drive and --link-dest Incremental backup takes up full disk space:

 @localhost media]$ ls orig ---------------------------------------------------- localhost media]$ du -sh . 25M . ---------------------------------------------------- localhost media]$ rsync -avh orig/ full ---------------------------------------------------- @localhost media]$ du -sh . 49M . ---------------------------------------------------- localhost media]$ echo 1111 > orig/foo111 ---------------------------------------------------- localhost media]$ rsync -avh --link-dest=full orig/ orig_1 ---------------------------------------------------- localhost media]$ ls orig_1/foo111 orig_1/foo111 _____________________________________________________ localhost media]$ ls full/foo111 ls: cannot access full/foo111: No such file or directory 

So far, everything looks good. The last change is reflected in orig_1 But the directories are not tightly connected, and they are all in full size.

 ----------------------------------------------------- localhost media]$ du -sh . 74M . --------------------------------------------- localhost media]$ du -sh orig_1/ 25M orig_1/ -------------------------------------------- localhost media]$ du -sh orig 25M orig --------------------------------------------- localhost media]$ du -sh full 25M full 

I assume that the size of orig_1 is 0? The stat command does not show hard links. What am I doing wrong?

+6
source share
3 answers

When you ran rsync -avh --link-dest=full orig/ orig_1 , you ignored this error message (this is more obvious if you remove -v ):

 --link-dest arg does not exist: full 

If we look at man rsync in the --link-dest section, we find:

 If DIR is a relative path, it is relative to the destination directory. 

And here it is. full refers to the current directory. Regarding the target directory, this will be ../full .

If you try again with rsync -avh --link-dest=../full orig/ orig_1 , you will get what you expect:

 $ du -sh * 149M full 149M orig 232K orig_1 $ du -sh . 298M . 

Please note that when counting separately, the directories are still displayed in full:

 $ du -sh orig_1 149M orig_1 

This is because du keeps track of files that it has already seen and avoids counting them twice.

+14
source

--link-dest accepts the path relative to the destination. You want --link-dest=../orig .

+4
source

Unix standard file systems do not allow hard links to directories, except for special links . and .. --link-dest creates only hard links for files, the rest of the directory structure is recreated as real directories.

And even if hard links were allowed for directories, du will still show the full size of each link. When using hard links, there is no difference between the original and the link, each of them is only names related to a specific index, and du will scan them equivalently.

-1
source

All Articles