GOT

Get Proactive!
PartnerNOC
Apr 8, 2003
1,524
201
343
Chesapeake, VA
cPanel Access Level
DataCenter Provider
So from time to time, an error gets into the backup process (usually a crashed database) and the backup drive gets full because backups are not pruning.

Used to be no big deal to just manually delete the older backups, but I am wondering if this is still possible given the hardlinking that is used. We are likely deleting files that are otherwise hard linked in other restore points, right?

So what is the best practice way to manually prune old backups when there is not enough remaining free space to run a complete backup set once the errors are resolved and get the old versions pruned automatically?
 

Jcats

Well-Known Member
PartnerNOC
May 25, 2011
797
151
168
New Jersey
cPanel Access Level
DataCenter Provider
That's what the "Strictly enforce retention, regardless of backup success" option is for, it will automatically remove them regardless.


"When the strictly-enforced retention behavior encounters failed backups, it keeps at least one successful backup, but deletes any backups that surpass the retention limit that you set in WHM's Backup Configuration interface."

Or maybe I didn't understand the question?
 

GOT

Get Proactive!
PartnerNOC
Apr 8, 2003
1,524
201
343
Chesapeake, VA
cPanel Access Level
DataCenter Provider
Yes that is true, but once you get to the point where there is not enough space for a full backup to run, that won't do anything since the backup cannot complete and pruning takes place at the end.
 

Jcats

Well-Known Member
PartnerNOC
May 25, 2011
797
151
168
New Jersey
cPanel Access Level
DataCenter Provider
It shouldn't ever get to that point though unless you just plain out don't have enough space on the drive in which case you have a different issue and should upgrade your disk space OR reduce the retention to not store as many days worth of backups.
 

GOT

Get Proactive!
PartnerNOC
Apr 8, 2003
1,524
201
343
Chesapeake, VA
cPanel Access Level
DataCenter Provider
We as a rule do not enable the prune anyway because it means that there is an issue with the backups. SOMETIMES it goes to far and the drive has less free space left than is needed to run the backup, just the way it is. We could of course delete ALL the backups, but it would be better to just delete enough to get to the point where a new backup can run and let the auto pruning do its thing.
 

Jcats

Well-Known Member
PartnerNOC
May 25, 2011
797
151
168
New Jersey
cPanel Access Level
DataCenter Provider
So your question is, you want an automated way of removing only x amount of backups to free up x amount of space to allow the backup process to complete in which it would then prune the backups as usual?
 

GOT

Get Proactive!
PartnerNOC
Apr 8, 2003
1,524
201
343
Chesapeake, VA
cPanel Access Level
DataCenter Provider
Basically, but I am not expecteing automated. I just want to know if it is safe to manually delete say ten or fifteen daily backup folders or not. Will the subsequent backup restore whatever source files that were there, or will it assume from the meta data that the source files are still there.
 

Jcats

Well-Known Member
PartnerNOC
May 25, 2011
797
151
168
New Jersey
cPanel Access Level
DataCenter Provider
Good question, so I am assuming you are primarily asking as the restore ability would still show an available backup when in fact it would not be available since it was manually deleted and the meta data remains.

I just tested this, and yes that would be the case but the next time the backups run, it repopulates the metadata so the backups you removed will not show.

So if you remove said backups, then run
Code:
/usr/local/cpanel/bin/backup
you will actually be ok since the metadata will get updated.
 

GOT

Get Proactive!
PartnerNOC
Apr 8, 2003
1,524
201
343
Chesapeake, VA
cPanel Access Level
DataCenter Provider
Actually, no, My concern is for the files that are hard linked. If I remove a source file that is hard linked else where, does the cPanel backup recognize this and back the source file up again and re-establish the hard links.
 

Jcats

Well-Known Member
PartnerNOC
May 25, 2011
797
151
168
New Jersey
cPanel Access Level
DataCenter Provider
That's not how hard links work, if you remove it from one location, it still remains in the other location, example:

Code:
[[email protected] ~]# mkdir -p original/test
[[email protected] ~]# mkdir -p link/test
[[email protected] ~]# touch original/test/hello
[[email protected] ~]# ln original/test/hello link/test/
[[email protected] ~]# ll original/test/hello
-rw-r--r-- 2 root root 0 Sep 28 09:23 original/test/hello
[[email protected] ~]# ll link/test/hello
-rw-r--r-- 2 root root 0 Sep 28 09:23 link/test/hello
[[email protected] ~]# rm -f original/test/hello
[[email protected] ~]# ll original/test/hello
ls: cannot access original/test/hello: No such file or directory
[[email protected] ~]# ll link/test/hello
-rw-r--r-- 1 root root 0 Sep 28 09:23 link/test/hello
You can see the original test file that was the source of the link was removed but the file remains, just down 1 link which is what the '1' indicates next to the permissions, where you saw it was a '2' after we linked it originally.

Same goes for your backups, if you remove an entire backup, that hardlink remains throughout the rest of the backups, each new backup is sourced from the previously taken backup, not the one about to be pruned unless there is only 1 set of backups.