Exemple #1
0
    def run(self, cmd, opts, *backupsets):
        if not backupsets:
            backupsets = hollandcfg.lookup("holland.backupsets")

        # strip empty items from backupsets list
        backupsets = [name for name in backupsets if name]

        if not backupsets:
            LOG.info("Nothing to backup")
            return 1

        runner = BackupRunner(spool)

        # dry-run implies no-lock
        if opts.dry_run:
            opts.no_lock = True

        # don't purge if doing a dry-run, or when simultaneous backups may be running
        if not opts.no_lock:
            purge_mgr = PurgeManager()

            runner.register_cb("before-backup", purge_mgr)
            runner.register_cb("after-backup", purge_mgr)
            runner.register_cb("failed-backup", purge_backup)

        runner.register_cb("after-backup", report_low_space)

        if not opts.dry_run:
            runner.register_cb("before-backup", call_hooks)
            runner.register_cb("after-backup", call_hooks)
            runner.register_cb("failed-backup", call_hooks)

        error = 1
        LOG.info("--- Starting %s run ---", opts.dry_run and "dry" or "backup")
        for name in backupsets:
            try:
                config = hollandcfg.backupset(name)
                # ensure we have at least an empty holland:backup section
                config.setdefault("holland:backup", {})
            except (SyntaxError, IOError), exc:
                LOG.error("Could not load backupset '%s': %s", name, exc)
                break

            if not opts.no_lock:
                lock = Lock(config.filename)
                try:
                    lock.acquire()
                    LOG.debug("Set advisory lock on %s", lock.path)
                except LockError:
                    LOG.debug("Unable to acquire advisory lock on %s", lock.path)
                    LOG.error("Another holland backup process is already " "running backupset '%s'. Aborting.", name)
                    break

            try:
                try:
                    runner.backup(name, config, opts.dry_run)
                except BackupError, exc:
                    LOG.error("Backup failed: %s", exc.args[0])
                    break
                except ConfigError, exc:
                    break
Exemple #2
0
    def run(self, cmd, opts, *backupsets):
        if not backupsets:
            backupsets = hollandcfg.lookup('holland.backupsets')

        # strip empty items from backupsets list
        backupsets = [name for name in backupsets if name]

        if not backupsets:
            LOG.info("Nothing to backup")
            return 1

        runner = BackupRunner(spool)

        # dry-run implies no-lock
        if opts.dry_run:
            opts.no_lock = True

        # don't purge if doing a dry-run, or when simultaneous backups may be running
        if not opts.no_lock:
            purge_mgr = PurgeManager()

            runner.register_cb('pre-backup', purge_mgr)
            runner.register_cb('post-backup', purge_mgr)
            runner.register_cb('backup-failure', purge_backup)

        runner.register_cb('post-backup', report_low_space)

        runner.register_cb('pre-backup', call_hooks)
        runner.register_cb('post-backup', call_hooks)
        runner.register_cb('backup-failure', call_hooks)

        error = 1
        LOG.info("--- Starting %s run ---", opts.dry_run and 'dry' or 'backup')
        for name in backupsets:
            try:
                config = hollandcfg.backupset(name)
                # ensure we have at least an empty holland:backup section
                config.setdefault('holland:backup', {})
            except (SyntaxError, IOError), exc:
                LOG.error("Could not load backupset '%s': %s", name, exc)
                break

            if not opts.no_lock:
                lock = Lock(config.filename)
                try:
                    lock.acquire()
                    LOG.info("Acquired lock %s : '%s'", lock.path, lock.lock.name)
                except LockError:
                    LOG.error("Failed to acquire lock on backupset %s (%s)",
                                name, config.filename)

                    break

            try:
                try:
                    runner.backup(name, config, opts.dry_run)
                except BackupError, exc:
                    LOG.error("Backup failed: %s", exc.args[0])
                    break
                except ConfigError, exc:
                    break
Exemple #3
0
    def run(self, cmd, opts, *backupsets):
        if not backupsets:
            backupsets = HOLLANDCFG.lookup('holland.backupsets')

        # strip empty items from backupsets list
        backupsets = [name for name in backupsets if name]

        if not backupsets:
            LOG.info("Nothing to backup")
            return 1

        runner = BackupRunner(SPOOL)

        # dry-run implies no-lock
        if opts.dry_run:
            opts.no_lock = True

        # don't purge if doing a dry-run, or when simultaneous backups may be running
        if not opts.no_lock:
            purge_mgr = PurgeManager()

            runner.register_cb('before-backup', purge_mgr)
            runner.register_cb('after-backup', purge_mgr)
            runner.register_cb('failed-backup', purge_backup)

        runner.register_cb('after-backup', report_low_space)

        if not opts.dry_run:
            runner.register_cb('before-backup', call_hooks)
            runner.register_cb('after-backup', call_hooks)
            runner.register_cb('failed-backup', call_hooks)

        error = 1
        LOG.info("--- Starting %s run ---", opts.dry_run and 'dry' or 'backup')
        for name in backupsets:
            try:
                config = HOLLANDCFG.backupset(name)
                # ensure we have at least an empty holland:backup section
                config.setdefault('holland:backup', {})
            except (SyntaxError, IOError) as exc:
                LOG.error("Could not load backupset '%s': %s", name, exc)
                break

            if not opts.no_lock:
                lock = Lock(config.filename)
                try:
                    lock.acquire()
                    LOG.debug("Set advisory lock on %s", lock.path)
                except LockError:
                    LOG.debug("Unable to acquire advisory lock on %s",
                              lock.path)
                    LOG.error(
                        "Another holland backup process is already "
                        "running backupset '%s'. Aborting.", name)
                    break

            try:
                try:
                    runner.backup(name, config, opts.dry_run)
                except BackupError as exc:
                    LOG.error("Backup failed: %s", exc.args[0])
                    break
                except ConfigError as exc:
                    break
            finally:
                if not opts.no_lock:
                    if lock.is_locked():
                        lock.release()
                    LOG.info("Released lock %s", lock.path)
        else:
            error = 0
        LOG.info("--- Ending %s run ---", opts.dry_run and 'dry' or 'backup')
        return error
Exemple #4
0
    def run(self, cmd, opts, *backupsets):
        if not backupsets:
            backupsets = hollandcfg.lookup('holland.backupsets')

        # strip empty items from backupsets list
        backupsets = [name for name in backupsets if name]

        if not backupsets:
            LOG.info("Nothing to backup")
            return 1

        runner = BackupRunner(spool)

        # dry-run implies no-lock
        if opts.dry_run:
            opts.no_lock = True

        # don't purge if doing a dry-run, or when simultaneous backups may be running
        if not opts.no_lock:
            purge_mgr = PurgeManager()

            runner.register_cb('pre-backup', purge_mgr)
            runner.register_cb('post-backup', purge_mgr)
            runner.register_cb('backup-failure', purge_backup)

        runner.register_cb('post-backup', report_low_space)

        runner.register_cb('pre-backup', call_hooks)
        runner.register_cb('post-backup', call_hooks)
        runner.register_cb('backup-failure', call_hooks)

        error = 1
        LOG.info("--- Starting %s run ---", opts.dry_run and 'dry' or 'backup')
        for name in backupsets:
            try:
                config = hollandcfg.backupset(name)
                # ensure we have at least an empty holland:backup section
                config.setdefault('holland:backup', {})
            except (SyntaxError, IOError), exc:
                LOG.error("Could not load backupset '%s': %s", name, exc)
                break

            if not opts.no_lock:
                lock = Lock(config.filename)
                try:
                    lock.acquire()
                    LOG.info("Acquired lock %s : '%s'", lock.path,
                             lock.lock.name)
                except LockError:
                    LOG.error("Failed to acquire lock on backupset %s (%s)",
                              name, config.filename)

                    break

            try:
                try:
                    runner.backup(name, config, opts.dry_run)
                except BackupError, exc:
                    LOG.error("Backup failed: %s", exc.args[0])
                    break
                except ConfigError, exc:
                    break