def run(self, cmd, opts, *args): """ get backup informantion and call print table """ if args: print("The list-backup command takes no arguments", file=sys.stderr) backup_list = list(SPOOL.list_backups()) if not backup_list: print("No backups") return 0 backupsets_seen = [] for backup in backup_list: if backup.backupset not in backupsets_seen: backupsets_seen.append(backup.backupset) print("Backupset[%s]:" % (backup.backupset)) # Read the backup.conf backup.load_config() plugin_name = backup.config.get("holland:backup", {})["plugin"] if not plugin_name: print("Skipping broken backup: %s" % backup.name) continue print("\t%s" % backup.name) if opts.verbose: print("\t", backup.info()) plugin = load_backup_plugin(plugin_name) plugin = plugin(backup.backupset, backup.config, backup.path) if hasattr(plugin, "info"): plugin_info = plugin.info() rec = re.compile(r"^", re.M) print(rec.sub("\t\t", plugin_info)) return 0
def run(self, cmd, opts, *args): """ get backup informantion and call print table """ if args: print("The list-backup command takes no arguments", file=sys.stderr) backup_list = [x for x in SPOOL.list_backups()] if not backup_list: print("No backups") return 0 backupsets_seen = [] for backup in backup_list: if backup.backupset not in backupsets_seen: backupsets_seen.append(backup.backupset) print("Backupset[%s]:" % (backup.backupset)) # Read the backup.conf backup.load_config() plugin_name = backup.config.get("holland:backup", {})["plugin"] if not plugin_name: print("Skipping broken backup: %s" % backup.name) continue print("\t%s" % backup.name) if opts.verbose: print("\t", backup.info()) plugin = load_backup_plugin(plugin_name) plugin = plugin(backup.backupset, backup.config, backup.path) if hasattr(plugin, "info"): plugin_info = plugin.info() import re rec = re.compile(r"^", re.M) print(rec.sub("\t\t", plugin_info)) return 0
def load_plugin(name, config, path, dry_run): """ Method to load plugins """ try: plugin_cls = load_backup_plugin(config["holland:backup"]["plugin"]) except KeyError as exc: raise BackupError("No plugin defined for backupset '%s'." % name) except PluginLoadError as exc: raise BackupError(str(exc)) try: return plugin_cls(name=name, config=config, target_directory=path, dry_run=dry_run) # commenting out the below in case we actually want to handle this one day # except (KeyboardInterrupt, SystemExit): # raise except Exception as exc: LOG.debug("Error while initializing %r : %s", plugin_cls, exc, exc_info=True) raise BackupError("Error initializing %s plugin: %s" % (config["holland:backup"]["plugin"], str(exc)))
def run(self, cmd, opts): backup_list = [x for x in spool.list_backups()] if not backup_list: print "No backups" return 0 backupsets_seen = [] for backup in backup_list: if backup.backupset not in backupsets_seen: backupsets_seen.append(backup.backupset) print "Backupset[%s]:" % (backup.backupset) # Read the backup.conf backup.load_config() plugin_name = backup.config.get('holland:backup', {})['plugin'] if not plugin_name: print "Skipping broken backup: %s" % backup.name continue print "\t%s" % backup.name if opts.verbose: print "\t", backup.info() plugin = load_backup_plugin(plugin_name) plugin = plugin(backup.backupset, backup.config, backup.path) if hasattr(plugin, 'info'): plugin_info = plugin.info() import re rec = re.compile(r'^', re.M) print rec.sub('\t\t', plugin_info) return 0
def load_plugin(name, config, path, dry_run): """ Method to load plugins """ try: plugin_cls = load_backup_plugin(config['holland:backup']['plugin']) except KeyError as exc: raise BackupError("No plugin defined for backupset '%s'.", name) except PluginLoadError as exc: raise BackupError(str(exc)) try: return plugin_cls(name=name, config=config, target_directory=path, dry_run=dry_run) except (KeyboardInterrupt, SystemExit): raise except Exception as exc: LOG.debug("Error while initializing %r : %s", plugin_cls, exc, exc_info=True) raise BackupError("Error initializing %s plugin: %s" % (config['holland:backup']['plugin'], str(exc)))
def run(self, cmd, opts): backup_list = [x for x in spool.list_backups()] if not backup_list: print "No backups" return 0 backupsets_seen = [] for backup in backup_list: if backup.backupset not in backupsets_seen: backupsets_seen.append(backup.backupset) print "Backupset[%s]:" % (backup.backupset) # Read the backup.conf backup.load_config() plugin_name = backup.config.get("holland:backup", {})["plugin"] if not plugin_name: print "Skipping broken backup: %s" % backup.name continue print "\t%s" % backup.name if opts.verbose: print "\t", backup.info() plugin = load_backup_plugin(plugin_name) plugin = plugin(backup.backupset, backup.config, backup.path) if hasattr(plugin, "info"): plugin_info = plugin.info() import re rec = re.compile(r"^", re.M) print rec.sub("\t\t", plugin_info) return 0
def load_plugin(name, config, path, dry_run): """ Method to load plugins """ try: plugin_cls = load_backup_plugin(config["holland:backup"]["plugin"]) except KeyError as exc: raise BackupError("No plugin defined for backupset '%s'." % name) except PluginLoadError as exc: raise BackupError(str(exc)) try: return plugin_cls(name=name, config=config, target_directory=path, dry_run=dry_run) # commenting out the below in case we actually want to handle this one day # except (KeyboardInterrupt, SystemExit): # raise except Exception as exc: LOG.debug("Error while initializing %r : %s", plugin_cls, exc, exc_info=True) raise BackupError( "Error initializing %s plugin: %s" % (config["holland:backup"]["plugin"], str(exc)) )
def load_plugin(name, config, path, dry_run): try: plugin_cls = load_backup_plugin(config['holland:backup']['plugin']) except KeyError, exc: raise BackupError("No plugin defined for backupset '%s'.", name)
try: backupset_cfg = load_backupset_config(backupset_name) except IOError, e: LOGGER.error("Failed to load backupset %s: %s", backupset_name, e) raise BackupError("Aborting due to previous errors.") except SyntaxError, e: LOGGER.error("Failed to load backupset config %r [%s]. %s", backupset_name, e.config.filename, e) LOGGER.error("Bad line appears to be '%s'", e.line) raise BackupError("Aborting due to previous errors.") # May raise a PluginError if the plugin could not be loaded LOGGER.info("Loading plugin %s", backupset_cfg.lookup('holland:backup.plugin')) try: plugincls = load_backup_plugin( backupset_cfg.lookup('holland:backup.plugin')) except PluginLoadError, e: LOGGER.error("Failed to load plugin %s: %s", backupset_cfg.lookup('holland:backup.plugin'), e) raise BackupError(e) # Possible IOError here if we cannot write to spool # Don't create the directory in dry-run mode backup_job = spool.add_backup(backupset_name) LOGGER.info("Prepared backup spool %s", backup_job.path) # Always merge in the backupset config to the backup-local config LOGGER.debug("Merging backupset config into local backup.conf config") backup_job.config.merge(backupset_cfg) backup_job.validate_config() # Plugin may fail to initialize due to programming error
except IOError, e: LOGGER.error("Failed to load backupset %s: %s", backupset_name, e) raise BackupError("Aborting due to previous errors.") except SyntaxError, e: LOGGER.error("Failed to load backupset config %r [%s]. %s", backupset_name, e.config.filename, e ) LOGGER.error("Bad line appears to be '%s'", e.line) raise BackupError("Aborting due to previous errors.") # May raise a PluginError if the plugin could not be loaded LOGGER.info("Loading plugin %s", backupset_cfg.lookup('holland:backup.plugin')) try: plugincls = load_backup_plugin(backupset_cfg.lookup('holland:backup.plugin')) except PluginLoadError, e: LOGGER.error("Failed to load plugin %s: %s", backupset_cfg.lookup('holland:backup.plugin'), e) raise BackupError(e) # Possible IOError here if we cannot write to spool # Don't create the directory in dry-run mode backup_job = spool.add_backup(backupset_name) LOGGER.info("Prepared backup spool %s", backup_job.path) # Always merge in the backupset config to the backup-local config LOGGER.debug("Merging backupset config into local backup.conf config") backup_job.config.merge(backupset_cfg) backup_job.validate_config() # Plugin may fail to initialize due to programming error