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

©XSIBackup: dynamically naming folders and resources

 Please note that this post is relative to old deprecated software ©XSIBackup-Classic. Some facts herein contained may still be applicable to more recent versions though.

For new instalations please use new ©XSIBackup which is far more advanced than ©XSIBackup-Classic.

©XSIBackup runs in the shell, it is a Bash script wich makes use of some binaries where more efficiency is required. The fact that it is a Bash script is not an accident, this allows customers to easily tweak ©XSIBackup-Pro to their needs and take advantage of some assets scripts have over compiled code, like being able to evaluate code.

It is a common problem among system administrators the need to name resources dynamically. Per instance, we might want to open a new XSITools repository every month and check the former, so that we can be sure our archived data is consistent and that a new repository is used as months pass. Or we might want to alternate backups in different repos, one per each day of the week. This way we would have one repository for Mondays, another one for Tuesdays, and so on. Casuistic is almost infinite, therefore we will try to cover some typical scenarios and leave the details to your particular needs.

©XSIBackup offers the --date-dir=yes option to generate timestamped folders, but you can use the power of the date function to create your own timestamps. Take on account that if you want to make use of the automatic deletion feature, you will need to use --date-dir=yes to make sure that the generated mask is exactly what ©XSIBackup looks for when deleting older folders to make room.

Open one XSITools repository per month

This is something like commented above and a very tipical need. To accomplish this we would only need to set a dinamic --backup-point argument:

./xsibackup ... --backup-point="/vmfs/volumes/backup/$(date +%Y%m)-xsitools"


The above code would just backup to the 201702-xsitools repository on February 2017 and to 201703-xsitools on march freeing us from the need to do it manually.

Backup to a different folder per day of the week

If what we want to achieve is what the title describes, then we just need to parse different arguments to the date function.

./xsibackup ... --backup-point="/vmfs/volumes/backup/$(date '+%a')-xsitools"


The above will generate folders like: Mon-xsitools, Tue-xsitools and so on.

Create a new Borg repository per month

To offer a different syntax, we can use the name abbreviation of the month in this case.

--backup-prog=borg --backup-point="192.168.3.232:22:/xsibak/$(date '+%b')-Borg"


The above --backup-point argument will generate folders such as: Apr-Borg, May-Borg, Jun-Borg and so on at the remote server 192.168.3.232.

Some more advanced examples

We can also combine more complicated (not much) bash expressions to achieve further results.

Backup to a quarterly generated folder

./xsibackup ... --backup-point="/vmfs/volumes/backup3/$( date +"%Y %m" | awk '{Q=int($2/4)+1; printf("%sQ%s\n", $1, Q);}' )"


Use two backup devices, one for even days and the other one for odd days

./xsibackup ... --backup-point="/vmfs/volumes/backup$( [ $(($(date +'%d')%2)) -eq 0 ] && echo EvenDays || echo OddDays )"


Backup to the even and odd days devices creating one new backup folder per quarter

./xsibackup ... --backup-point="/vmfs/volumes/backup$( [ $(($(date +'%d')%2)) -eq 0 ] && echo EvenDays || echo OddDays )"/$( date +"%Y %m" | awk '{Q=int($2/4)+1; printf("%sQ%s\n", $1, Q);}' )



XSITools and space provisioning

As you may already know, ©XSIBackup is able to provision space should your datastore get full of backup data. Nevertheless, to avoid deleting things that you want to preserve, it will only delete folders that meet a predefined naming convention. The mask that is applied to backup folders is set in the conf/xsiopts file, and only that mask will be sought when locating folders to delete. In the above examples we have used folder names that do not follow this mask pattern, thus they will not be considered for deletion once the datastore fills up.

The reason not to do that is that XSITools repositories may hold hundreds of VMs, so deleting them is not something that should be done automatically, unless you explicitly decide so. Depending on you backup folder's organization, you could be storing XSITools backups in weekly, monthly, alternate days folders, etc..., whatever is the type of structure you use, you may find it useful to give folders created with XSITools a name so that they will still be considered for automatic deletion. If that is your case, you could chose some automatic naming in the following fashion.

./xsibackup ... --backup-point="/vmfs/volumes/backup/$(date +%Y%m'00000000')


The above will generate a folder per month, storing XSITools data there, should the datastore fill up, it will be considered for automatic deletion. It's up to you to decide what's the period to use based on your datastore size and your needs.