Exemple #1
0
    def snapshot(self):
        logger.debug("Making snapshot")
        self.clear_target()
        exclusions = []
        try:
            for obj_data in self.conf.objects:
                logger.debug("Dumping: %s", obj_data)
                self.action_single(obj_data, action='snapshot')
                if 'exclude' in obj_data:
                    exclusions += (
                        os.path.join(obj_data['path'], ex).lstrip('/')
                        for ex in obj_data['exclude']
                    )

            logger.debug("Dumping shotgun log "
                         "and archiving dump directory: %s",
                         self.conf.target)
            self.action_single(self.conf.self_log_object, action='snapshot')

            utils.compress(self.conf.target, self.conf.compression_level,
                           exclude=exclusions)

            with open(self.conf.lastdump, "w") as fo:
                fo.write("{0}.tar.gz".format(self.conf.target))
        except IOError as e:
            if e.errno == errno.ENOSPC:
                logger.error("Not enough space in "
                             "{} for snapshot".format(self.conf.target))
                self.clear_target()
            raise

        return "{0}.tar.gz".format(self.conf.target)
Exemple #2
0
    def snapshot(self):
        logger.debug("Making snapshot")
        for obj_data in self.conf.objects:
            logger.debug("Dumping: %s", obj_data)
            driver = Driver.getDriver(obj_data, self.conf)
            driver.snapshot()
        logger.debug("Archiving dump directory: %s", self.conf.target)

        compress(self.conf.target, self.conf.compression_level)

        with open(self.conf.lastdump, "w") as fo:
            fo.write("{0}.tar.xz".format(self.conf.target))
        return "{0}.tar.xz".format(self.conf.target)
Exemple #3
0
    def snapshot(self):
        logger.debug("Making snapshot")
        utils.execute("rm -rf {0}".format(os.path.dirname(self.conf.target)))
        for obj_data in self.conf.objects:
            logger.debug("Dumping: %s", obj_data)
            driver = Driver.getDriver(obj_data, self.conf)
            driver.snapshot()
        logger.debug("Archiving dump directory: %s", self.conf.target)

        utils.compress(self.conf.target, self.conf.compression_level)

        with open(self.conf.lastdump, "w") as fo:
            fo.write("{0}.tar.xz".format(self.conf.target))
        return "{0}.tar.xz".format(self.conf.target)
Exemple #4
0
    def test_compress(self, mexecute):
        target = '/path/target'
        level = '-3'

        utils.compress(target, level)

        compress_call = mexecute.call_args_list[0]
        rm_call = mexecute.call_args_list[1]

        compress_env = compress_call[1]['env']
        self.assertEqual(compress_env['XZ_OPT'], level)
        self.assertEqual(compress_call[0][0],
                         'tar cJvf /path/target.tar.xz -C /path target')

        self.assertEqual(rm_call[0][0], 'rm -r /path/target')
Exemple #5
0
    def test_compress(self, mexecute):
        target = '/path/target'
        level = '-3'

        utils.compress(target, level)

        compress_call = mexecute.call_args_list[0]
        rm_call = mexecute.call_args_list[1]

        compress_env = compress_call[1]['env']
        self.assertEqual(compress_env['XZ_OPT'], level)
        self.assertEqual(
            compress_call[0][0],
            'tar cJvf /path/target.tar.xz -C /path target')

        self.assertEqual(rm_call[0][0], 'rm -r /path/target')
Exemple #6
0
    def snapshot(self):
        logger.debug("Making snapshot")
        utils.execute("rm -rf {0}".format(os.path.dirname(self.conf.target)))
        for obj_data in self.conf.objects:
            logger.debug("Dumping: %s", obj_data)
            self.action_single(obj_data, action='snapshot')

        logger.debug("Dumping shotgun log and archiving dump directory: %s",
                     self.conf.target)
        self.action_single(self.conf.self_log_object, action='snapshot')

        utils.compress(self.conf.target, self.conf.compression_level)

        with open(self.conf.lastdump, "w") as fo:
            fo.write("{0}.tar.xz".format(self.conf.target))
        return "{0}.tar.xz".format(self.conf.target)
Exemple #7
0
    def snapshot(self):
        logger.debug("Making snapshot")
        utils.execute("rm -rf {0}".format(os.path.dirname(self.conf.target)))
        for obj_data in self.conf.objects:
            logger.debug("Dumping: %s", obj_data)
            self.action_single(obj_data, action='snapshot')

        logger.debug("Dumping shotgun log and archiving dump directory: %s",
                     self.conf.target)
        self.action_single(self.conf.self_log_object, action='snapshot')

        utils.compress(self.conf.target, self.conf.compression_level)

        with open(self.conf.lastdump, "w") as fo:
            fo.write("{0}.tar.xz".format(self.conf.target))
        return "{0}.tar.xz".format(self.conf.target)
Exemple #8
0
    def test_compress_exclude(self, mexecute):
        target = '/path/target'
        level = '-3'

        exclusions = ['/path/to/exclude1', '/path/to/exclude2']

        mexecute.return_value = (None, None, None)

        utils.compress(target, level, exclude=exclusions)

        compress_call = mexecute.call_args_list[0]

        compress_env = compress_call[1]['env']
        self.assertEqual(compress_env['XZ_OPT'], level)
        self.assertEqual(
            compress_call[0][0],
            'tar chzf /path/target.tar.gz -C /path target '
            '--exclude=/path/to/exclude1 --exclude=/path/to/exclude2')