Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

disk usage issue with rsync and --link-dest

I have disk usage problem with rsync and --link-dest Incremental backup is taking 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

Everything looks good so far. The latest change is reflected in orig_1 But the directories aren't hard linked and they're 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

Am I suppose to have the orig_1 size as 0? And stat command shows no hard links. What am I doing wrong?

like image 396
user3059831 Avatar asked Jan 23 '14 02:01

user3059831


1 Answers

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

--link-dest arg does not exist: full

If we then take a look at man rsync under --link-dest, we find:

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

And there it is. full is relative to the current directory. Relative to the destination directory, it would be ../full.

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

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

Note that, when counted individually, the directories still appear take up the full space:

$ du -sh orig_1 
149M    orig_1

This is because du keeps track of files it's already seen, and avoids counting them twice.

like image 111
that other guy Avatar answered Sep 19 '22 15:09

that other guy