Python: Clone snapshot into VM

Hi, I write currently a little backup tool in Python which use the following workflow: - create a snapshot -> works - clone snapshot into VM -> help needed - delete the snapshot -> works - export VM to NFS share -> works - delete cloned VM -> TODO Is it possible to clone a snapshot into a VM like from the web-interface? The above workflow is a little bit resource expensive but it will when it is finished make Online-Full-backups of VM's. cheers gregor

On 09/15/2015 11:57 AM, gregor wrote:
Hi,
I write currently a little backup tool in Python which use the following workflow: - create a snapshot -> works - clone snapshot into VM -> help needed
snapshot = params.Snapshot(id=api.vms.get('my_vm01').snapshots.list(description='my_vm_snap_01')[0].id) snapshots = params.Snapshots(snapshot=[snapshot]) api.vms.add(params.VM(name='new_vm', memory=2524971008, cluster=api.clusters.get("Default"), snapshots=snapshots))
- delete the snapshot -> works - export VM to NFS share -> works - delete cloned VM -> TODO
Is it possible to clone a snapshot into a VM like from the web-interface?
The above workflow is a little bit resource expensive but it will when it is finished make Online-Full-backups of VM's.
cheers gregor _______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users

Hi, thanks, the tool is ready and online on github. https://github.com/wefixit-AT/oVirtBackup cheers gregor On 2015-09-16 15:11, Amador Pahim wrote:
On 09/15/2015 11:57 AM, gregor wrote:
Hi,
I write currently a little backup tool in Python which use the following workflow: - create a snapshot -> works - clone snapshot into VM -> help needed
snapshot = params.Snapshot(id=api.vms.get('my_vm01').snapshots.list(description='my_vm_snap_01')[0].id)
snapshots = params.Snapshots(snapshot=[snapshot])
api.vms.add(params.VM(name='new_vm', memory=2524971008, cluster=api.clusters.get("Default"), snapshots=snapshots))
- delete the snapshot -> works - export VM to NFS share -> works - delete cloned VM -> TODO
Is it possible to clone a snapshot into a VM like from the web-interface?
The above workflow is a little bit resource expensive but it will when it is finished make Online-Full-backups of VM's.
cheers gregor _______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users

tor 2015-09-17 klockan 21:24 +0200 skrev gregor:
Hi,
thanks, the tool is ready and online on github.
Looks really cool. Good job! What do you think of making the backing up into a loop and fetching VMs from a list? My thinking is that you usually have more than one VM you´d want to back up, so something like this maybe: def getVMsFromList(VMS_LIST): try: print 'Getting list of VMs from file \"%s\".' % (VMS_LIST) fo = open(VMS_LIST) output = [] for line in fo: strippedline = line.strip('\r\n') output.append(strippedline) fo.close() return output except Exception as e: print 'Exception in getting list of VMs:\n%s' % str(e) exit(1) And then you can loop: for LIST_VM_NAME in getVMsFromList('VMs.list'): .... Or to have the list of VMs in the config and then: config = Config(config_file, debug) VMS_LIST = vms_list for LIST_VM_NAME in getVMsFromList(VMS_LIST): .... /K
https://github.com/wefixit-AT/oVirtBackup
cheers gregor
On 2015-09-16 15:11, Amador Pahim wrote:
On 09/15/2015 11:57 AM, gregor wrote:
Hi,
I write currently a little backup tool in Python which use the following workflow: - create a snapshot -> works - clone snapshot into VM -> help needed
snapshot = params.Snapshot(id=api.vms.get('my_vm01').snapshots.list(description='my_vm_snap_01')[0].id)
snapshots = params.Snapshots(snapshot=[snapshot])
api.vms.add(params.VM(name='new_vm', memory=2524971008, cluster=api.clusters.get("Default"), snapshots=snapshots))
- delete the snapshot -> works - export VM to NFS share -> works - delete cloned VM -> TODO
Is it possible to clone a snapshot into a VM like from the web-interface?
The above workflow is a little bit resource expensive but it will when it is finished make Online-Full-backups of VM's.
cheers gregor _______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users

Hi, this was also an idea but with the single backup script you have the advantage of backing up more than one VM at a time to speed up the overall backup time and therefore to backup to different clusters and different export domains. But I will change the tool to set a list of VM's in the configuration to cover both ways. greetings gregor On 2015-09-18 07:50, Karli Sjöberg wrote:
tor 2015-09-17 klockan 21:24 +0200 skrev gregor:
Hi,
thanks, the tool is ready and online on github.
Looks really cool. Good job! What do you think of making the backing up into a loop and fetching VMs from a list? My thinking is that you usually have more than one VM you´d want to back up, so something like this maybe:
def getVMsFromList(VMS_LIST): try: print 'Getting list of VMs from file \"%s\".' % (VMS_LIST) fo = open(VMS_LIST) output = [] for line in fo: strippedline = line.strip('\r\n') output.append(strippedline) fo.close() return output except Exception as e: print 'Exception in getting list of VMs:\n%s' % str(e) exit(1)
And then you can loop: for LIST_VM_NAME in getVMsFromList('VMs.list'): ....
Or to have the list of VMs in the config and then: config = Config(config_file, debug) VMS_LIST = vms_list for LIST_VM_NAME in getVMsFromList(VMS_LIST): ....
/K
https://github.com/wefixit-AT/oVirtBackup
cheers gregor
On 2015-09-16 15:11, Amador Pahim wrote:
On 09/15/2015 11:57 AM, gregor wrote:
Hi,
I write currently a little backup tool in Python which use the following workflow: - create a snapshot -> works - clone snapshot into VM -> help needed
snapshot = params.Snapshot(id=api.vms.get('my_vm01').snapshots.list(description='my_vm_snap_01')[0].id)
snapshots = params.Snapshots(snapshot=[snapshot])
api.vms.add(params.VM(name='new_vm', memory=2524971008, cluster=api.clusters.get("Default"), snapshots=snapshots))
- delete the snapshot -> works - export VM to NFS share -> works - delete cloned VM -> TODO
Is it possible to clone a snapshot into a VM like from the web-interface?
The above workflow is a little bit resource expensive but it will when it is finished make Online-Full-backups of VM's.
cheers gregor _______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users

Hi, a new version is available on github which supports a list of VM's in the config. https://github.com/wefixit-AT/oVirtBackup cheers gregor On 2015-09-18 07:50, Karli Sjöberg wrote:
tor 2015-09-17 klockan 21:24 +0200 skrev gregor:
Hi,
thanks, the tool is ready and online on github.
Looks really cool. Good job! What do you think of making the backing up into a loop and fetching VMs from a list? My thinking is that you usually have more than one VM you´d want to back up, so something like this maybe:
def getVMsFromList(VMS_LIST): try: print 'Getting list of VMs from file \"%s\".' % (VMS_LIST) fo = open(VMS_LIST) output = [] for line in fo: strippedline = line.strip('\r\n') output.append(strippedline) fo.close() return output except Exception as e: print 'Exception in getting list of VMs:\n%s' % str(e) exit(1)
And then you can loop: for LIST_VM_NAME in getVMsFromList('VMs.list'): ....
Or to have the list of VMs in the config and then: config = Config(config_file, debug) VMS_LIST = vms_list for LIST_VM_NAME in getVMsFromList(VMS_LIST): ....
/K
https://github.com/wefixit-AT/oVirtBackup
cheers gregor
On 2015-09-16 15:11, Amador Pahim wrote:
On 09/15/2015 11:57 AM, gregor wrote:
Hi,
I write currently a little backup tool in Python which use the following workflow: - create a snapshot -> works - clone snapshot into VM -> help needed
snapshot = params.Snapshot(id=api.vms.get('my_vm01').snapshots.list(description='my_vm_snap_01')[0].id)
snapshots = params.Snapshots(snapshot=[snapshot])
api.vms.add(params.VM(name='new_vm', memory=2524971008, cluster=api.clusters.get("Default"), snapshots=snapshots))
- delete the snapshot -> works - export VM to NFS share -> works - delete cloned VM -> TODO
Is it possible to clone a snapshot into a VM like from the web-interface?
The above workflow is a little bit resource expensive but it will when it is finished make Online-Full-backups of VM's.
cheers gregor _______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
participants (3)
-
Amador Pahim
-
gregor
-
Karli Sjöberg