Incremental backups and hardlinks question

postcd

Well-Known Member
Oct 22, 2010
721
21
68
Hello, i read Backup Configuration - Documentation - cPanel Documentation

Incremental — Select this setting to save all of your files in the "directory tree." This setting uses hard links to save disk space. However, only files different from the previous backup will use disk space.
I see that when i compare one identic file from two daily backups directories they use same inode:
stat faq.php ../../../../../2017-08-24/accounts/cpanelname/homedir/www/faq.php
File: `faq.php'
Size: 1843 Blocks: 8 IO Block: 4096 regular file
Device: 9007h/36871d Inode: 59901396 Links: 8
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2017-08-28 08:00:01.338758490 +0000
Modify: 2012-06-06 08:06:50.000000000 +0000
Change: 2017-08-28 02:42:48.745287488 +0000
File: `../../../../../2017-08-24/accounts/cpanelname/homedir/www/faq.php'
Size: 1843 Blocks: 8 IO Block: 4096 regular file
Device: 9007h/36871d Inode: 59901396 Links: 8
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2017-08-28 08:00:01.338758490 +0000
Modify: 2012-06-06 08:06:50.000000000 +0000
Change: 2017-08-28 02:42:48.745287488 +0000

So when i backup either one using "rsync -av" or "tar -czf", i will have working file thanks to hardlink?

But what if the destination file (not hardlink) gets deleted, then all rest daily backup directories will not be able to resolve this file as hardlink will point to no file?

So it means WHM admins should not manually delete any directories in /backup to prevent missing files shared among archives?

When i rsync to other server, i will need to do 1:1 of a /backup folder, else if i miss some daily backups, it can result that some files will be inaccessible because hardlinks will point to a missing file?
 
Last edited:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,258
463
Hello,

The remote incremental backup process (with rsync) is designed to check if the files associated with the account backup on the cPanel server also exist on the remote backup destination. If the files do not exist on the remote backup destination (or if the files have changed), then it copies the actual files. Otherwise, it makes use of hard links when the files already exist on the remote backup destination. The following document is available if you'd like to read more about how account backup information is stored:

Metadata for Backups - Version 66 Documentation - cPanel Documentation

Thank you.
 

brt

Well-Known Member
Jul 9, 2015
105
10
68
US
cPanel Access Level
Root Administrator
This confused me at first too, trying to figure out how incremental backups were working using date-named directories that were eventually deleted.

A hard link is different than a Windows-type "shortcut". Your first copy of a file is just a file. The second instance of that same identical file also appears as a file -- an identical file -- but the two (or more) are actually one and the same. Either one can be deleted, and the other will remain as a completely normal file.

Every "copy" of a hardlink/file basically increments a "copy count" on the original/only actual file, and deleting any of the hardlinks/files just decreases that copy count by one until there's only one remaining, at which point another delete removes the file.

Hopefully that makes more sense.