Last updated on Monday 28th of February 2022 08:52:48 PM
©XSIBackup: troubleshooting the cron service
Procedure to check the ESXi cron service and put it to work
This post applies to both the Free and Pro versions of the software. The only difference in regards to the cron facility is that in the Pro version you have the option to enter the schedules in a window, instead having to edit text files with vi. No big deal in regards to how things work, apart from having to pay extra attention to how you write cron lines.
Up until version 11.0.0 XSIBackup used a crontab named xsibackup-cron which was placed in the root xsi-dir installation directory. This worked well for some time and users got used to it. Nevertheless, it was an abstraction created not to have to deal with the ESXi crontab, which is not persistent and on top of that is a very basic piece of code which lacks control code and a proper service init system. As a result, the possibilities it offered were limited to scheduling weekly backups, and setting up a daily backup would require generating a mask for each of the seven days.
With the upcoming of version 11.0.0 we have solved this limitations by saving the schedules in a crontab that's now named root-crontab and is placed inside the /conf folder, relative to the root installation directory. The contents of this file are just copied over to the /var/spool/cron/crontabs/root when the system reboots, or when you invoke the --update-cron argument.
The new system allows to employ classic Linux/ Unix crontab syntax, so now, there isn't any constraint in the way you may program your schedules. You can have daily, weekly, monthly, etc... schedules as per the ESXi Linux crontab, which is bundled in the busybox binary shipped with ESXi.
The Day Of Week column in ©ESXi may need to be passed as the day abbreviation: mon, tue, wed, thu, fry, sat, sun. If we say "may", it is because every ESXi version has a different busybox implementation and the cron daemon implementation it contains is not like the most sophisticated ones you can find in advanced Linux distros. So try to keep your schedules simple and should you need to use the DoW column, try different numerical formats and also abbreviations.
Add > /dev/null 2>&1 at the end of backup jobs to redirect everything to /dev/null. As backup job output is previously redirected to the xsibackup.log file all output text will be stored there, doing this can prevent some awkward behaviours from part of the shell.
0 2 * * * "/vmfs/volumes/datastore1/xsi-dir/jobs/001" > /dev/null 2>&1
XSIBackup takes care of checking the crond binary is loaded just once and that the contents of the /conf/root-crontab file are copied to the ESXI crontab when using the --update-cron argument, so the chances the ESXi crond binary hangs are very little if you just use XSIBackup commands and do not deal with the ESXi command line directly.
If you can't get your XSIBackup job to be fired, there is some procedure that you should follow. Follow it blindly, if you go your own way we cannot predict the results. The matter is fairly simple:
1/ Make sure your backup job is working. Call it by means of the --run-backup argument, or just execute the job by calling it with an absolute path, i.e: /vmfs/volumes/datastore1/xsi-dir/jobs/001 and run tail -f /vmfs/volumes/datastore1/xsi-dir/conf/xsibackup.log in a different window.Now, if you have a working cron daemon and a working backup job, the only chances that your jobs are not being executed, is that you are using a wrong path somewhere.
If you don't have a working cron daemon, then your ESXi installation is broken, or you missed some step above. A loaded crond daemon must write the date to the test file as the root user is "all mighty" and the /tmp folder allows everyone to write there.
There are always chances that you did something wrong: edited the cron file with an editor that changed the page code, so the cron daemon is not able to read it, misplaced some element in the cron file, etc... If that is your case, you don't know what to do and you don't comprehend some of the facts involved, then just reinstall ESXi from scratch and follow this troubleshooting guide editing the files with vi. If you don't know how vi (AKA vim) works, then read this guide: https://www.howtogeek.com/102468/a-beginners-guide-to-editing-text-files-with-vi/
We all had to learn, sometimes the hard way. If you pretend to use XSIBackup, you need to have or acquire some basic Linux command line skills. Our support department is not there to take your hand and teach you the basics.
Always check your log to see what the XSIBackup process may have written to it in search of errors and warnings. Change the number of lines (-n20) to suit your needs.
tail -n20 /vmfs/volumes/datastore1/xsi-dir/conf/xsibackup.log
Daniel J. García Fidalgo