You are not logged in.
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
Offline
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 [b]^W.*0[/b]
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
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
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
[quote=admin]Well, we didn't pretend to reach perfection in an ad-hoc written code snippet, just to point you in the right direction.
[/quote]
I didn't assume so and also did not expect perfection. That's why I wrote
[quote]Thank you very much for your code snippet - it pointed me in the right direction.
[/quote]
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
We didn't see it as such
Offline