def _archive_info(self, i): status = "Unknown" if i.status is not None: status = dar_status(int(i.status)) else: r = Report(i.job.name) locks = r.s.query(Lock).filter(Lock.cat_id == i.id).all() for l in locks: if l.check_pid(): status = "Running" break return Table( Col("", ["Job ID", "Job name", "Job type", "Encryption", "Created", "Comment", "Clean", "Status", "Parent", "Hierarchy", "Time Took"]), Col("", [ i.id, i.job.name, i.type.name, i.enc, i.date.strftime("%c"), i.comment, i.clean, status, i.parent, i.hierarchy, #when running ttookk will be none, we must figutre out #how much has been taking. timedelta(seconds=i.ttook) ], "-"))
def do_backup(self, arg, opts=None): '''Perform a backup task''' if opts: try: s = Scheme(self.cf, opts.job, opts.root) self.stdout.write('Running backup job: %s..\n' % opts.job) s.run(opts.full) ttook = timedelta(seconds=s.newcatalog.ttook) stat = dar_status(s.newcatalog.status) self.report('Dar status:\t\t%s\nTime took:\t\t%s\n' % (stat, ttook), opts.job, verbose=opts.verbose, catalog=s.newcatalog) except RefCatalogError, e: self.report( 'The reference catalog is missing, please ' 'provide one or force a full backup.\n', opts.job, error=True) except ConfigException, e: self.report( '\nThere seems to be a configuration error:\n' ' %s\n' % e.message, opts.job, error=True)
self.stdout.write("Outdated DMD please rebuild it or recover " "manually.\n") sys.exit(2) if opts.extract: cat = opts.jobid if opts.jobid else None try: run = s.recover_all( rpath, stdout=self.stdout, stderr=sys.stderr, catalog=cat) except RecoverError, e: sys.stderr.write("%s\n" % e.message) sys.exit(2) else: run = s.recover_from_dmd(opts.file, rpath, when=opts.when) self.stdout.write("\n %s \n" % dar_status(run[0].returncode)) self.stdout.write("Stdout: %s" % run[1][0]) self.stdout.write("Stderr: %s" % run[1][1]) @options([ mkarg('-i', '--id', default=None, help="Limit operation to specified" " backup id."), mkarg('-j', '--job', default=None, help='Limit operation to jobname'), mkarg('filename', help="output filename (\"-\" for stdout)")]) def do_dbrecover(self, arg, opts=None): '''Load a db backup to file or stdout.''' if not opts.id and not opts.job: sys.stderr.write("Please specify either -j or -i options.\n") else: if opts.id: r = Report(None)