DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2010-06-14 14:04:20

sulan
Member
Registered: 2010-04-02
Posts: 17

Size of incremental backup

I'm using rsync to make incremental backups using hard links. However when I want to check the size of a particular backup by doing "du -hc newly_created_backup_dir" it reports the full size, which of course is fully correct. My question is not how to find out the exact size of the backup?

Up till now I've been using the "df" command, but since the disk change by other processes during a backup this isn't a very good solution. So, does anyone have any hints on how to solve it, maybe using some rsync functionality?

Offline

 

#2 2010-06-14 20:31:58

karlrado
Member
Registered: 2009-12-07
Posts: 229

Re: Size of incremental backup

I *think* you are asking for a way to find out the actual space used by the backups, incorporating the "savings" of the hard links.

In order to do this with du, you have to provide du with the multiple directories that span the hard links, so that it can tell if there is more than one link to a single file.  When it encounters multiple links to the same file, it only counts the space used by the file once.  If you merely provide it with one of your backup dirs, du is forced to just report the size of any files it finds, because there are no other directories containing hard links in your request.

When you create a file in dir A and make a hard link to it in dir B, the file exists on the same footing in both A and B.  That is, you cannot think of it as the "real" file being in A and a "link" to it is in B.  The file is out in the filesystem and just happens to have a link to it from both A and B.

So "du A" and "du B" will both report actual sizes of the files in A and B.  But "du A B" will let du discover if any files are linked to both A and B and will count the actual size of files linked to both only once.  The '-l' option on du reverses this behavior.

In your case, you will want to say:

"du -hc not_so_newly_created_backup_dir newly_created_backup_dir"

or perhaps:

"du -hc directory_containing_my_backups/*"


I use rsnapshot (highly recommended) and to demonstrate:

root@Toaster:/backup/Snapshots# du -cs hourly.0
390107468       hourly.0
390107468       total
root@Toaster:/backup/Snapshots# du -cs hourly.1
390107456       hourly.1
390107456       total
root@Toaster:/backup/Snapshots# du -cs hourly.0 hourly.1
390107468       hourly.0
119800  hourly.1
390227268       total


Note that if I run du on ONE backup directory, I get the sizes of every file in that directory.  Note that it does not matter which one I include in the du command.

If I run du with more than one backup directory, then sizes of files with more than one link to them are only added in once.  In this case, very few files changed, so most of the files have links to both hourly.0 and hourly.1.  The size of the hourly.1 directory is mostly the cost of the extra links in hourly.1.

I suppose that it is just a du convention to report the sizes of files linked to both hourly.0 and hourly.1 in hourly.0.

Last edited by karlrado (2010-06-14 20:49:14)


DNS-323 FW 1.07 : 2 1TB WD Caviar Green SATA : fun_plug: utelnet + optware (no ffp)

Offline

 

#3 2010-06-15 00:07:32

sulan
Member
Registered: 2010-04-02
Posts: 17

Re: Size of incremental backup

Great, thanks. I tried to run the du command on the directory that contains all backups and it worked like charm. However it took about 45 minutes to finnish due to the large amount of data.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB