NAUbackup / VmBackup

XenServer simple backup script
228 stars 61 forks source link

regex filtering for vm-export not working for me #43

Closed ilium007 closed 6 years ago

ilium007 commented 7 years ago

The vm-export regex filtering is not working for me.

I have two VM's:

In the config file I can specify:

vm-export=prd_win.*

and I will get the Windows server

and:

vm-export=prd_linux.*

and I will get the Ubuntu host

but if I specify:

vm-export=prd_.*

I only get the Ubuntu one in the script output.

If I specify them separately in the config file like below:

vm-export=prd_win. vm-export=prd_linux.

I see both in the script output:

2017-05-05-(17:06:36) - VmBackup config loaded from: /snapshots/NAUbackup/xenserver01.cfg 2017-05-05-(17:06:36) - VmBackup.py running with these settings: 2017-05-05-(17:06:36) - backup_dir = /snapshots/BACKUPS 2017-05-05-(17:06:36) - status_log = /snapshots/NAUbackup/status.log 2017-05-05-(17:06:36) - compress = False 2017-05-05-(17:06:36) - max_backups = 7 2017-05-05-(17:06:36) - vdi_export_format = raw 2017-05-05-(17:06:36) - pool_db_backup = 1 2017-05-05-(17:06:36) - exclude (cnt)= 0 2017-05-05-(17:06:36) - exclude: 2017-05-05-(17:06:36) - vdi-export (cnt)= 0 2017-05-05-(17:06:36) - vdi-export: 2017-05-05-(17:06:36) - vm-export (cnt)= 2 2017-05-05-(17:06:36) - vm-export: prd_win_server2016_64bit_01, prd_linux_ubuntu1404_01

I expect that when I use the following I should get both hosts marked for backups:

vm-export=prd_.*

ilium007 commented 7 years ago

I have found the issue.

In the "save_to_config_export" method you are mutating the all_vms list within the loop that is iterating over all_vms. Once the list has been mutated the loop exits hence after the first match the call to "all_vms.remove(vm)" causes the loop to exit.

This line is not required and when commented out the code works as expected.

Submitting a pull request now for this.

NAUbackup commented 7 years ago

I have reviewed this and can verify the issue as well as the fix. I am in the process of performing some additional testing and plan to incorporate this update into the next minor release. Thank you for your contribution. --Tobias

NAUbackup commented 7 years ago

I hope to have a fixed release of this out soon and have been doing some testing. Thank you for your patience. --Tobias

NAUbackup commented 6 years ago

Fixed and incorporated into V3.2.