#1 2018-03-20 15:17:51

tim
Member
Registered: 2018-03-15
Posts: 5

Extended XSIBackup crontab help [Resolved]

Hello,

I'm following the instructions found in this blog post. I would like to backup my VMs just once per month, on the given day and time if the day of the month is between the 17th and 23rd. I have tested the schedule by adding the following in my xsibackup-cron file:

run_this_at="Tue 15:07"
current_day_of_month=$(date +%d)

if [ "$run_this_at" != "" ]
then
    if [ "$run_this_at" == "$( date +"%a %H:%M" )" -a $current_day_of_month -ge 17 -a $current_day_of_month -le 23 ]
    then
        echo "test"
    fi
fi

This works as expected and the word test can be found in the xsibackup-cron.log.

I then expanded the code above to try and execute xsibackup. Here's the updated xsibackup-cron file:

run_this_at="Tue 15:07"
current_day_of_month=$(date +%d)

if [ "$run_this_at" != "" ]
then
    if [ "$run_this_at" == "$( date +"%a %H:%M" )" -a $current_day_of_month -ge 17 -a $current_day_of_month -le 23 ]
    then
        echo "test"
        /vmfs/volumes/datastore1/xsi-dir/xsibackup --backup-point="/vmfs/volumes/backups" --backup-how=cold --backup-type=custom --backup-vms="fw2"
    fi
fi

Again, "test" is logged in xsibackup-cron.log at the desired time. However, the "fw2" VM is not backed up and nothing else is written in the log after "test".

Can you please let me know what I'm doing wrong? I'm not very familiar with bash scripts and am probably just missing something small.

Thanks!

Edit: Sorry, I just realized that I was in the Pro forum. This should have been posted in the free forum. Can you please move it for me?

Last edited by tim (2018-03-21 13:36:07)

Offline

#2 2018-03-21 10:10:25

admin
Administrator
Registered: 2017-04-21
Posts: 1,370

Re: Extended XSIBackup crontab help [Resolved]

You have totally rewritten our example, I'm sorry sir but we don't correct code here.
On the other side, you are missing some arguments in your XSIBackup job: --backup-prog being the most important one.
On addition XSIBackup will expect the job to include a --time argument when called from the cron, thus you should add the directive --exec=yes to your job
I suggest that you try your command in the command line before using it.

Offline

#3 2018-03-21 13:34:56

tim
Member
Registered: 2018-03-15
Posts: 5

Re: Extended XSIBackup crontab help [Resolved]

Thank you for your reply. With your assistance I was able to resolve the issue.

admin wrote:

You have totally rewritten our example, I'm sorry sir but we don't correct code here.

I worked on this for quite a while, looked at logs, read the help man page, searched your blog posts and searched the forums. I thought the next logical step was to ask for assistance and felt that the support forum was the appropriate place for that? I had mentioned the code part worked as expected (it writes "test" to the log at the desired time). The only line that I needed help with was the one that actually executes xsibackup. In retrospect, I probably should have used the code in the blog post example and just substituted the echo command for my xsibackup command to help reduce distractions to the actual problem.

admin wrote:

On the other side, you are missing some arguments in your XSIBackup job: --backup-prog being the most important one.

According to the documentation, --backup-prog has a default value of vmkfstools for datastore backups, which is my desired value.

admin wrote:

On addition XSIBackup will expect the job to include a --time argument when called from the cron, thus you should add the directive --exec=yes to your job

Thank you, adding --exec=yes resolved the issue. I do not see this directive listed in help man page or in the last few cron related blog posts. Now that I know what to look for, I did find it in this blog post. I kindly ask that the --exec directive be included to the help man page to help others in the future.

admin wrote:

I suggest that you try your command in the command line before using it.

I apologize for forgetting to mention that I did run it from the command line and when I do so, it works as expected (it just seems like such a natural thing to do that I didn't think of including that info).

Offline

#4 2018-03-21 14:10:29

sistemi
Member
Registered: 2017-08-29
Posts: 71

Re: Extended XSIBackup crontab help [Resolved]

Damn, i thought i was so near to heaven, no way to make it working, what's wrong here?

All working from command line, test date formati is weekday-hh-mm, doing ps -c|grep xsibackp i see the /bin/sh ... etc..., but joust for a moment, nothing on the log or .ERR

if [ "$(date '+%u-%H-%M')" == "3-14-03" ]
then
     # usb mount
     esxcli storage nfs add -H 192.168.1.1 -v usb -s /USBDisk2/

     /vmfs/volumes/datastore1/xsi-dir/xsibackup backupid=E1BAKtoUSB --exec=yes --backup-prog=xsitools:z --backup-how=hot --override=xsibakfilter --backup-type=custom --test-mode=false --use-smtp=1 --mail-to=xxxxxxxx --subject="test backup" --backup-point=/vmfs/volumes/usb/aaaaaaa --debug-info=yes --backup-vms=zzz

     #usb umount
     esxcli storage nfs remove  -v usb
fi

Offline

#5 2018-03-21 15:15:34

tim
Member
Registered: 2018-03-15
Posts: 5

Re: Extended XSIBackup crontab help [Resolved]

If nothing is being logged then there might be a syntax error in your code (that's what I found when I had syntax errors). Try putting

echo "test"

or something similar early in your file and see if it's written to the log. If not, then you may have a syntax error. Comment out code until you find the offending line and then focus on that.

You can also try checking the /var/log/syslog.log for errors there.

Although this is related to the extended crontab backups, it's not quite related to my issue. You might be better off creating a new forum post.

Offline

#6 2018-03-22 11:52:31

admin
Administrator
Registered: 2017-04-21
Posts: 1,370

Re: Extended XSIBackup crontab help [Resolved]

sistemi wrote:

Damn, i thought i was so near to heaven, no way to make it working, what's wrong here?

All working from command line, test date formati is weekday-hh-mm, doing ps -c|grep xsibackp i see the /bin/sh ... etc..., but joust for a moment, nothing on the log or .ERR

if [ "$(date '+%u-%H-%M')" == "3-14-03" ]
then
     # usb mount
     esxcli storage nfs add -H 192.168.1.1 -v usb -s /USBDisk2/

     /vmfs/volumes/datastore1/xsi-dir/xsibackup backupid=E1BAKtoUSB --exec=yes --backup-prog=xsitools:z --backup-how=hot --override=xsibakfilter --backup-type=custom --test-mode=false --use-smtp=1 --mail-to=xxxxxxxx --subject="test backup" --backup-point=/vmfs/volumes/usb/aaaaaaa --debug-info=yes --backup-vms=zzz

     #usb umount
     esxcli storage nfs remove  -v usb
fi

Get used to employ leading zeros in dates.
In other order of things, for goodness sake, don't use USB devices to backup your VMs. USB is a nice method to plug your key and copy your office documents, but it's not a serious mean to backup critical data. If you don't know what I mean, I bet you'll end up knowing why we are vehement about it ;-)

Offline

#7 2018-03-23 09:49:36

sistemi
Member
Registered: 2017-08-29
Posts: 71

Re: Extended XSIBackup crontab help [Resolved]

sistemi wrote:

Get used to employ leading zeros in dates.
In other order of things, for goodness sake, don't use USB devices to backup your VMs. USB is a nice method to plug your key and copy your office documents, but it's not a serious mean to backup critical data. If you don't know what I mean, I bet you'll end up knowing why we are vehement about it ;-)

the test works, but the job is not launched, as i told i see the command line if i execute ps -c|grep xsibackup, but it last in just a second and there is no log to check...

Offline

#8 2018-03-23 14:01:58

admin
Administrator
Registered: 2017-04-21
Posts: 1,370

Re: Extended XSIBackup crontab help [Resolved]

Make sure the --exec=yes directive is at the end of the backup job string

Offline

#9 2018-03-23 14:10:30

sistemi
Member
Registered: 2017-08-29
Posts: 71

Re: Extended XSIBackup crontab help [Resolved]

admin wrote:

Make sure the --exec=yes directive is at the end of the backup job string

yes, figured out debugging the script... now it works!

Offline

Board footer