©XSIBackup-Free: Free Backup Software for ©VMWare ©ESXi

Forum ©XSIBackup: ©VMWare ©ESXi Backup Software


You are not logged in.

#1 2021-06-22 06:31:46

Int
Member
Registered: 2017-12-05
Posts: 58

use regexp for VMs source selection in XSIBackup-DC

Could you please explain how to use regexp for VMs source selection in XSIBackup-DC?

I tried different variants like --backup "VMs(REGEXP(^PROD))", --backup "REGEXP(^PROD)", ...
none of them works.


I am currently in the process of migrating from XSIBackup-Pro Classic to XSIBackup-DC Datacenter Edition.
I would like to use the regular expression for VM selection that I established in XSIBackup-Pro Classic.
If this does not work I would have to manually create large lists of VMs, which I would like to avoid.


The documentation only explains the optional regexp pattern to exclude disks from the backup.

Could you please add how to use regexp pattern for the source selection to
https://33hops.com/xsibackup-dc-full-ma … tml#source

Offline

#2 2021-06-22 10:30:40

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

Re: use regexp for VMs source selection in XSIBackup-DC

By now you can only select groups of VMs by using the keywords RUNNING or ALL.
REGEXP support for selection of VMs will be added in short, you can nonetheless easily implement this in the very DC job by using this code snippet.
The grep expresssion contains the regular expression that you use to filter the VMs, in this example it is ^W.*0

vim-cmd vmsvc/getallvms | tail -n+2 | awk -F '[' '{print $1}' | awk '{print $2}' | grep -E "^W.*0" | sed ':a;N;$!ba;s/\n/,/g'

This code snippet integrated in a job would look something like this:

/vmfs/volumes/6071af03-9b59286b-5ed6-001517c3fbf5/XSI/XSIBackup-DC/xsibackup \
--backup \
"VMs($(vim-cmd vmsvc/getallvms | tail -n+2 | awk -F '[' '{print $1}' | awk '{print $2}' | grep -E "^W.*0" | sed ':a;N;$!ba;s/\n/,/g'))" \
/xsibackups/xsibackup_default_repository \
--mail-to=mail-from \
>> /vmfs/volumes/6071af03-9b59286b-5ed6-001517c3fbf5/XSI/XSIBackup-DC/var/log/xsibackup.log 2>&1

The code snippet takes  all the VMs in the host, then it filters them by using the regular expression in the grep command to finally remove the new line characters and substitute them by a comma, which is the VM separator in a VM list.

You can test the code in the command line prior to using it in a job.

Offline

#3 2021-06-25 14:01:48

Int
Member
Registered: 2017-12-05
Posts: 58

Re: use regexp for VMs source selection in XSIBackup-DC

Thank you very much for your code snippet - it pointed me in the right direction.

Your code has some flaws. It doesn't work properly when the VM name contains spaces or when the VM annotation/description contains newlines.

I modified your code to address these two issues. This is what I came up with:

vim-cmd vmsvc/getallvms | sed -e '1d' -e 's/ \[.*$//' | awk '$1 ~ /^[0-9]+$/ {print substr($0,8,80)}' | grep -E "^W.*0" | sed ':a;N;$!ba;s/ *\n/,/g' | xargs

Offline

#4 2021-06-25 17:49:12

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

Re: use regexp for VMs source selection in XSIBackup-DC

Well, we didn't pretend to reach perfection in an ad-hoc written code snippet, just to point you in the right direction.
Nonetheless, try to avoid fancy names in VMs or paths.

Offline

#5 2021-06-26 14:30:06

Int
Member
Registered: 2017-12-05
Posts: 58

Re: use regexp for VMs source selection in XSIBackup-DC

admin wrote:

Well, we didn't pretend to reach perfection in an ad-hoc written code snippet, just to point you in the right direction.

I didn't assume so and also did not expect perfection. That's why I wrote

Thank you very much for your code snippet - it pointed me in the right direction.

I shared my improved code to help other users of xsibackup.

You shouldn't treat each post which is pointing out a flaw as a criticism.

Offline

#6 2021-06-27 12:05:47

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

Re: use regexp for VMs source selection in XSIBackup-DC

We didn't see it as such

Offline

Board footer