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

©XSIBackup Classic, Advanced cron, custom variables

 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.

Note (2017-05-10): you can still use this very same technique to assign any variables that you want, in any case, the examples are a bit outdated, as since version 9 ©XSIBackup-Pro Classic counts with an SMTP server panel where you preconfigure any information about outcoming e-mails.

As we have stated many times before, ©XSIBackup Classic has been designed to be flexible, so that you can integrate it in other systems, no matter what their aim may be.

One simple example of this would be the use of custom variables in the xsibackup-cron file. Why would you want to do that?. Let's say that you will be sending your e-mail reports through a single e-mail account, that'd be very natural. You might not want to write down the e-mail server, the e-mail from, to, username and password for every backup job. Thus it would be of great help to have all this values stored in variables and use those variables to reference those values accross the xsibackup-cron file.

The aim is simple, right?. In fact it is so simple that you can do it right in the very same xsibackup-cron file. It's O.K., and that will work, but only with XSIBACKUP-FREE and also with ©XSIBackup-Pro Classic, just as long as you are not chaining backups. We will offer both solutions here:


SIMPLEST SCENARIO, no chained backups

This case is very simple, you just have to write down the variables with whatever names you want and asign them values that will be used further down in the xsibackup-cron.

#!/bin/sh

emserv=smtp.yourdomain.com
emsrvp=587
mailto=john.smith@yourdomain.com
mailfr=john.smith@yourdomain.com
emuser=john.smith@yourdomain.com
empass=MySecurePasswd

# This is your ©XSIBackup Classic crontab, you can add your backup sechedules here
# You can use regular ©XSIBackup Classic commands appending the parameter --time="Day HH:mm", i.e. --time="Mon 21:57"
# The --time format is compounded by three letters weekday acronym (Mon,Tue,Wed,Thu,Fri,Sat,Sun) + space + hh:mm
# You can add multiple "moments" in a --time argument separated by a pipeline | like: Mon 17:31|Tue 21:33|Sun 19:21
#
# Example:
/vmfs/volumes/datastore1/xsibackup-dir/xsibackup backupId=00 --time="Mon 02:00|Tue 02:00|Wed 02:00|Thu 02:00|Fri 02:00|Sat 02:00" --date-dir=yes --backup-point="/vmfs/volumes/backup3" --backup-type=custom --backup-vms="WPRO01,WXP01,WDES01,WDES02,LCENT64,LCENT53" --mail-from=$mailfr --mail-to="$mailto" --smtp-srv=$emserv --smtp-port=$emsrvp --smtp-usr=$emuser --smtp-pwd=$empass --smtp-sec=TLS


Not much more to say about this kind of variable substitution but taking care of not commiting syntax mistakes. This will just assign values to this vars and use them in the execution context of the xsibackup crontab (xsibackup-cron).


©XSIBackup-Pro Classic with chained backups

In this case the latter will only work for the first backup job in the chain. Why?, because it is the only backup job that gets fired from within the crontab context. The subsequent backups will get fired from ©XSIBackup-Pro Classic execution context, and thus, those variables created in the crontab file will be empty, to be more precise: they will not exist.

To overcome this situation, and also to extend ©XSIBackup-Pro Classic capabilities, from version 6.0.8, ©XSIBackup-Pro Classic loads any file present in its directory with an ".inc" extension as a source file. You can use then an .inc file to store your variables and then include this file manually in the crontab, so that these variables will be available to both the crontab and the ©XSIBackup-Pro Classic executable.

#!/bin/sh

source /vmfs/volumes/datastore1/xsi-dir/email_vars.inc

# This is your ©XSIBackup Classic crontab, you can add your backup sechedules here
# You can use regular ©XSIBackup Classic commands appending the parameter --time="Day HH:mm", i.e. --time="Mon 21:57"
# The --time format is compounded by three letters weekday acronym (Mon,Tue,Wed,Thu,Fri,Sat,Sun) + space + hh:mm
# You can add multiple "moments" in a --time argument separated by a pipeline | like: Mon 17:31|Tue 21:33|Sun 19:21
#
# Example:
/vmfs/volumes/datastore1/xsibackup-dir/xsibackup backupId=00 --time="Mon 02:00|Tue 02:00|Wed 02:00|Thu 02:00|Fri 02:00|Sat 02:00" --date-dir=yes --backup-point="/vmfs/volumes/backup3" --backup-type=custom --backup-vms="WPRO01,WXP01,WDES01,WDES02,LCENT64,LCENT53" --mail-from=$mailfr --mail-to="$mailto" --smtp-srv=$emserv --smtp-port=$emsrvp --smtp-usr=$emuser --smtp-pwd=$empass --smtp-sec=TLS


Provided that your ©XSIBackup-Pro Classic installation directory is the default /vmfs/volumes/datastore1/xsi-dir/, and that the file containing your variables is called email_vars.inc, your xsibackup-cron file would look like the above.

The cronfile will load the vars by means of the line

source /vmfs/volumes/datastore1/xsi-dir/email_vars.inc

So, they will be available to the xsibackup-cron file, and on the other side ©XSIBackup-Pro Classic will load any ".inc" file present at its installations dir, including "email_vars.inc", so those variables will also be available to ©XSIBackup-Pro Classic.

Be careful not to use any reserved system keyword or any variable name that ©XSIBackup Classic uses as part of its functioning.