예제 #1
0
def restore_done(result, backupID, outfd, tarfilename, outputlocation,
                 callback_method):
    global _WorkingBackupIDs
    global _WorkingRestoreProgress
    global OnRestoreDoneFunc
    if result == 'done':
        lg.info('restore success of %s with result=%s' % (backupID, result))
    else:
        lg.err('restore failed of %s with result=%s' % (backupID, result))
    try:
        os.close(outfd)
    except:
        lg.exc()
    if result == 'done':
        d = backup_tar.extracttar_thread(tarfilename, outputlocation)
        d.addCallback(extract_done, backupID, tarfilename, outputlocation,
                      callback_method)
        d.addErrback(extract_failed, backupID, tarfilename, outputlocation,
                     callback_method)
        return d
    _WorkingBackupIDs.pop(backupID, None)
    _WorkingRestoreProgress.pop(backupID, None)
    tmpfile.throw_out(tarfilename, 'restore ' + result)
    if OnRestoreDoneFunc is not None:
        OnRestoreDoneFunc(backupID, result)
    if callback_method:
        try:
            callback_method(backupID, result)
        except:
            lg.exc()
    return result
예제 #2
0
 def _on_restore_done(self, result, backupID, outfd, tarfilename):
     try:
         os.close(outfd)
     except:
         lg.exc()
     if result == 'done':
         lg.info('archive %r restore success from %r' % (
             backupID,
             tarfilename,
         ))
     else:
         lg.err('archive %r restore failed from %r with : %r' % (
             backupID,
             tarfilename,
             result,
         ))
     if result == 'done':
         _, pathID, versionName = packetid.SplitBackupID(backupID)
         service_dir = settings.ServiceDir('service_private_groups')
         queues_dir = os.path.join(service_dir, 'queues')
         queue_dir = os.path.join(queues_dir, self.group_key_id)
         snapshot_dir = os.path.join(queue_dir, pathID, versionName)
         if not os.path.isdir(snapshot_dir):
             bpio._dirs_make(snapshot_dir)
         d = backup_tar.extracttar_thread(tarfilename, snapshot_dir)
         d.addCallback(self._on_extract_done, backupID, tarfilename,
                       snapshot_dir)
         d.addErrback(self._on_extract_failed, backupID, tarfilename,
                      snapshot_dir)
         return d
     tmpfile.throw_out(tarfilename, 'restore ' + result)
     return None
예제 #3
0
 def _do_extract_archive(self, backup_id, tarfilename, backup_index):
     snapshot_dir = tmpfile.make_dir('restore', extension='.msg')
     d = backup_tar.extracttar_thread(tarfilename, snapshot_dir)
     d.addCallback(self._on_extract_done, backup_id, tarfilename,
                   snapshot_dir, backup_index)
     d.addErrback(self._on_extract_failed, backup_id, tarfilename,
                  snapshot_dir)
     return d
예제 #4
0
 def _restore_done(result, backupID, outfd, tarfilename,
                   outputlocation):
     assert result == 'done'
     d = backup_tar.extracttar_thread(tarfilename, outputlocation)
     d.addCallback(_extract_done, backupID, tarfilename, outputlocation)
     return d