Exemplo n.º 1
0
    def execute(self):
        conf = self.conf
        logging.info('[*] Executing FS restore...')
        restore_timestamp = None

        restore_abs_path = conf.restore_abs_path
        if conf.restore_from_date:
            restore_timestamp = utils.date_to_timestamp(conf.restore_from_date)
        if conf.backup_media == 'fs':
            builder = tar.TarCommandRestoreBuilder(
                conf.tar_path, restore_abs_path, conf.compression,
                winutils.is_windows())
            if conf.dry_run:
                builder.set_dry_run()
            if winutils.is_windows():
                os.chdir(conf.restore_abs_path)
            if conf.encrypt_pass_file:
                builder.set_encryption(conf.openssl_path,
                                       conf.encrypt_pass_file)

            backup = self.storage.find_one(conf.hostname_backup_name,
                                           restore_timestamp)

            self.engine.restore(backup, restore_abs_path)
            return

        res = restore.RestoreOs(conf.client_manager, conf.container)
        if conf.backup_media == 'nova':
            res.restore_nova(conf.nova_inst_id, restore_timestamp)
        elif conf.backup_media == 'cinder':
            res.restore_cinder_by_glance(conf.cinder, restore_timestamp)
        elif conf.backup_media == 'cindernative':
            res.restore_cinder(conf.cinder_vol_id, restore_timestamp)
        else:
            raise Exception("unknown backup type: %s" % conf.backup_media)
Exemplo n.º 2
0
    def execute(self):
        conf = self.conf
        logging.info('[*] Executing FS restore...')
        restore_timestamp = None

        restore_abs_path = conf.restore_abs_path
        if conf.restore_from_date:
            restore_timestamp = utils.date_to_timestamp(conf.restore_from_date)
        if conf.backup_media == 'fs':
            backup = self.storage.find_one(conf.hostname_backup_name,
                                           restore_timestamp)

            self.engine.restore(backup, restore_abs_path)
            return {}

        res = restore.RestoreOs(conf.client_manager, conf.container)
        if conf.backup_media == 'nova':
            res.restore_nova(conf.nova_inst_id, restore_timestamp)
        elif conf.backup_media == 'cinder':
            res.restore_cinder_by_glance(conf.cinder_vol_id, restore_timestamp)
        elif conf.backup_media == 'cindernative':
            res.restore_cinder(conf.cindernative_vol_id, restore_timestamp)
        else:
            raise Exception("unknown backup type: %s" % conf.backup_media)
        return {}
Exemplo n.º 3
0
    def execute(self):
        if self.conf.remove_from_date:
            timestamp = utils.date_to_timestamp(self.conf.remove_from_date)
        else:
            timestamp = datetime.datetime.now() - \
                datetime.timedelta(days=self.conf.remove_older_than)
            timestamp = int(time.mktime(timestamp.timetuple()))

        self.storage.remove_older_than(timestamp,
                                       self.conf.hostname_backup_name)
Exemplo n.º 4
0
 def test_date_to_timestamp(self):
     # ensure that timestamp is check with appropriate timezone offset
     assert (1417649003 + time.timezone) == utils.date_to_timestamp(
         "2014-12-03T23:23:23")
Exemplo n.º 5
0
 def execute(self):
     timestamp = utils.date_to_timestamp(self.conf.remove_from_date)
     self.storage.remove_older_than(timestamp,
                                    self.conf.hostname_backup_name)