Registered users
Linkedin Twitter Facebook Google+
  This website uses its own cookies or from third parties Close
33HOPS, IT Consultants
33HOPS ::: Proveedores de Soluciones Informáticas :: Madrid :+34 91 663 6085Avda. Castilla la Mancha, 95 - local posterior - 28700 S.S. de los Reyes - MADRID33HOPS, Sistemas de Informacion y Redes, S.L.Info

<< Return to index

XSIBACKUP ::: Advanced cron: alternatives to xsibackup-cron

Some users have more complex scheduling requirements than what can be achieved with a combination of weekday and time, this post is for them.

XSIBackup's crontab file (xsibackup-cron) is a way to schedule weekly backups, ranging from "once a week" to "every day" schedules. This covers the vast majority of user's needs and allows to keep cron programming simple. Nevertheless, there are cases in which some Sysadmin wants to configure a scheduled task that goes beyond what can be easily achieved with XSIBackup's default scheduling system.

Let's say that you want to configure a backup to be run every hour. It might be a small VM that we might want to backup or a OneDiff diff backup to keep a mirror VM in sync. In this particular scenarios performing an hourly backup may be perfectly feasible and reasonable. So, let's delve into the different options we have when we need to get out of the road.

You have basically two options to program more flexible schedules: one of them is to change XSIBackup's date mask to accomodate your needs, the second option is to use ESXi's root crontab directly.

1) Change XSIBackup's date mask:

XSIBackup uses time stamps in the form "Mon 13:23" that are matched against the same pattern for the current time. The xsibackup-cron file is called every minute from the ESXi's crontab at /var/spool/cron/crontabs/root and if any of the configured times is matched at any backup job line, then XSIBackup execution is performed. The [Day Of Week]+[Time] is coded into the string parsed to the date function (+"%a %H:%M"). To tweak this, you must change this string to any value supported by the Linux date function.



Once you have accomplished the above, just use the same mask to define --time in your xsibackup-cron file. Let's use an example to concrete the described procedure into something more tangible:

You may use the following date stamp: date +"%M" for the (*)NOW (Please, note that the asterisk sign is not part of the source code, just a way to highlight the NOW variable) variable, that will give you the minute of the hour. If you then configure your xsibackup-cron file to run a job with a --time argument like the one shown below, you will get your cron to execute the job every time the minutes of the hour are "00", and thus you'll be executing the job every hour on the "00" minute. You can use any minute from 00 to 59 to have your backup executed that minute every hour.

2) Use ESXi root crontab:

You can also use the ESXi's crontab to execute your XSIBackup jobs. This is fairly easy: first of all just test your backup job interactively and add it to a text file, you can name it however you want and you must place it in a persistent path. Future versions of XSIBackup will use the xsi-dir/conf/jobs as the steady path to store this kind of files, so please stick to it. We'll use the file xsi-dir/conf/jobs/my-backup.job, this file needs to be executable for the ESXi cron to be able to run it, so you'll need to change its permissions this way:



Once your backup job has been tested (you never know if a sequence of commands contains any errors until you test it) you can place it to the above file adding the additional argument --exec=yes at the end of the backup job line. This last argument is fundamental for the ESXi's cron to execute the job.

Now that you have the backup job ready to be triggered, just edit the ESXi's root crontab in the path /var/spool/cron/crontabs/root and add the job as you would do in any other Linux or Unix environment. ATENTION: please note that the /var/spool/cron/crontabs/root file does not have write permissions by default, so you will need to change them before editing it, otherwise you won't be able to save the modifications you make.



Website Map
Consultancy
IT Manager
In Site
Resources & help
Index of Docs
33HOPS Forum

Fill in to download
The download link will be sent to your e-mail.
Name
Lastname
E-mail


            Read our Privacy Policy