Last updated on Monday 28th of February 2022 08:52:48 PM

©XSIBackup-DC: pruning from Linux

Prunning scripts

We already discussed about the prunning process in our previous post Pruning Old Backups.

You should have some basic concepts clear so far: finding the blocks to prune is fast, actually deleting the blocks will take some time, the slower the FS is, the longer it will take to delete each block.

Thus, it seems clear, that deleting the blocks over NFS is not a good idea, as network latency times will have to be added on top of HD seek time. Then the best thing to do when pruning big repositories is to do it from the backup server itself, no matter if it's mounted over NFS or you are performing the backups over IP. Well, when pruning on over IP scenarios, the pruning is already made from the server side, thus this post will mainly apply to NFS mounted datastores.

Or being more straight: backups made over IP are conceptually superior to those made to mounted local NFS shares and they free you from the hassle to have to prune big repositories with a separate server side script.

In any case, for those of you still willing to do your backups to an NFS mount, you might need a way to prune your repos from the backup server OS context, instead as from the ©ESXi shell due to the above exposed reasons.

©XSIBackup-DC is a Linux binary, you can just use it as any other Linux binary. Then, the best way to prune backups would be to use find to collect the backup folders older than X days and then use the xsibackup binary to prune them via the --prune argument.

Below, the short one liner script that allows you to do so.

find /path/to/the/root/of/your/repo -maxdepth 1 -mtime +20 -type d \
-regextype posix-egrep -regex "^/.*[0-9]{14}$" -exec xsibackup --prune {} \;


Explanation:

The find command is executed on the root of a repository. We use the -maxdepth 1 argument to select folders one level below (the backup folders).

We then use the -mtime +20 switch to select folders which are older than 20 days. We also want to make sure that we select only directories, hence the -type d (select directories).

Next arguments are relative to a regex filter that will allow us to select only the folders we want, namely: the ones that follow the timestamp rule of the backup folders YYYYDDMMhhmmss.

-regextype posix-egrep -regex "^/.*[0-9]{14}$"

As find returns absolute paths, we select strings starting by a slash (/) and ending in 14 numeric characters. Then the absolute paths are passed on to xsibackup --prune, where the {} \; represents each of the absolute paths.

Daniel J. García Fidalgo
33HOPS