cancel
Showing results for 
Search instead for 
Did you mean: 

Copy Backup Jobs

 
Highlighted
Advisor

Copy Backup Jobs

Hello to all,

i´ve got an implementation of new cubes at a customer site. Now i would like to copy the existing backups to the new federation. From the gui it is possible to copy the jobs but only one after another. Selecting more backup jobs doen´t give you the menue point "copy backups". With the cli it is also not to comfortable because the use of wildcarts is very limited so are my abilities to write a script.

I once had a copy backup script from SimpliVity that did the job but with the version 3.7.x it doesnt work anymore.

Could someone please tell me an easy way to copy the backups to the new federation? Any help is appreciated

 

Cheers,

Nick

3 REPLIES 3
Highlighted
HPE Pro

Re: Copy Backup Jobs

It's not possible to copy backups between federations but you can between clusters.you can certainly copy single backups but that is not great option if you have thosands of backups.

Is the original cluster being decommissioned ?


Probably best to open a support case a script should exist.

I am an HPE employee
Accept or Kudo
Highlighted
HPE Pro

Re: Copy Backup Jobs

@NZamp, The script that @DaveOb is referring to is this one:

#!/usr/bin/env python
'''
This script will move VM backups from one cluster to another, VM-by-VM.

USAGE: ./backup_move.py --vm <vm> --datastore <datastore> --source_cluster <source_cluster> --destination_cluster <destination_cluster>

'''

import argparse
import subprocess
import sys
import xml.etree.ElementTree as etree

def parse_args():
    '''Parse command line arguments'''

    parser = argparse.ArgumentParser()

    parser.add_argument('--vm',
                        required=True,
                        help="Specify the VM name")

    parser.add_argument('--datastore',
                        required=True,
                        help="Specify the source datastore")

    parser.add_argument('--source_cluster',
                        required=True,
                        help="Specify the source cluster")

    parser.add_argument('--destination_cluster',
                        required=True,
                        help="Specify the destination cluster")

    return parser.parse_args()

class Parameter(object):
    '''Create Parameter dictionary and strip UUIDs'''

    def __init__(self, name):
        self.name = name
        self.value = []

    def __len__(self):
        return len(self.value)

    def __getitem__(self, key):
        return self.value[key]

    def add(self, line):
        '''Strip XML and append to a list'''
        xml = etree.fromstring(line)
        value = etree.tostring(xml, encoding='UTF-8', method='text')
        self.value.append(value)

def enumerate_backups(vm, datastore):
    '''Use svt-backup-show to enumerate backups'''

    command = subprocess.check_output(['svt-backup-show',
                                       '--vm', vm,
                                       '--datastore', datastore,
                                       '--output', 'xml',
                                       '--max-results', '25000'])
    temp = command.splitlines()

    virtual_machine = Parameter('virtual_machine')
    backup = Parameter('backup')
    datastore = Parameter('datastore')

    for line in temp:

        if 'hiveName' in line: virtual_machine.add(line)
        elif 'name'   in line: backup.add(line)
        elif 'dsId'   in line: datastore.add(line)

    return (virtual_machine, backup, datastore)

def move_backup(args):
    '''Calculate backup unique bytes'''

    virtual_machine, backup, datastore = enumerate_backups(args.vm, args.datastore)

    zipper = zip(virtual_machine, backup, datastore)

    for index, (virtual_machine,
                backup,
                datastore) in enumerate(zipper, start=1):
        try:
            print "* Copying {}({}) backup {} of {}".format(backup, virtual_machine, index, len(zipper))

            subprocess.check_output(['svt-backup-copy',
                                     '--vm', virtual_machine,
                                     '--backup', backup,
                                     '--datastore', datastore,
                                     '--src-cluster', args.source_cluster,
									 '--dst-cluster', args.destination_cluster])

        except subprocess.CalledProcessError as error:
            pass

if __name__ == '__main__':

    ARGS = parse_args()

    move_backup(ARGS)

 Please note, this is provided as-is with no warranty of any kind. While I am a HPE employee, this is not the work of HPE.

Let me know if this works for you.

I am an HPE employee
Accept or Kudo
Highlighted
Advisor

Re: Copy Backup Jobs

Hello Scott,

the script works on machines that are still running on the old cluster. The backups are copied with no problems but when i try to copy a backup of a machine that is already migrated, i get the error "ERROR [10]: Unknown VM or VM not found in datastore or VM not stored by SimpliVity.". When i use the gui i can copy the backups without a problem.

Cheers,

Nick