fatal("'%s' is an invalid API-KEY" % apikey) try: sub_apikey = hub.Backups.get_sub_apikey(apikey) except Exception, e: fatal(e) registry.registry.sub_apikey = sub_apikey hb = hub.Backups(sub_apikey) try: credentials = hb.get_credentials() registry.registry.credentials = credentials print "Linked TKLBAM to your Hub account." except hub.NotSubscribed, e: print "Linked TKLBAM to your Hub account but there's a problem:" print elif not force_profile and registry.registry.profile: fatal("already initialized") if force_profile or not registry.registry.profile: try: registry.update_profile(conf.force_profile) except hub.Backups.NotInitialized: fatal("--solo requires --force-profile=empty or --force-profile=path/to/custom/profile ") if __name__=="__main__": main()
(address, raw_download_path)) downloader(raw_download_path, target, log=_print if not silent else None, debug=opt_debug, force=opt_force) return raw_download_path if raw_download_path: get_backup_extract() return else: raw_download_path = TempDir(prefix="tklbam-") os.chmod(raw_download_path, 0700) update_profile(conf.force_profile, strict=False) if not (opt_simulate or opt_debug): log_fh = file(opt_logfile, "a") print >> log_fh print >> log_fh, "\n" + fmt_timestamp() log_fh.flush() trap = UnitedStdTrap(usepty=True, transparent=(False if silent else True), tee=log_fh) else: trap = None
def _print(s): print s def get_backup_extract(): print fmt_title("Executing Duplicity to download %s to %s " % (address, raw_download_path)) downloader(raw_download_path, target, log=_print if not silent else None, debug=opt_debug, force=opt_force) return raw_download_path if raw_download_path: get_backup_extract() return else: raw_download_path = TempDir(prefix="tklbam-") os.chmod(raw_download_path, 0700) update_profile(conf.force_profile, strict=False) if not (opt_simulate or opt_debug): log_fh = file(opt_logfile, "a") print >> log_fh print >> log_fh, "\n" + fmt_timestamp() log_fh.flush() trap = UnitedStdTrap(usepty=True, transparent=(False if silent else True), tee=log_fh) else: trap = None try: hooks.restore.pre()
if opt_simulate and registry.backup_resume_conf and not opt_disable_resume: fatal("--simulate will destroy your aborted backup session. To force use --disable-resume") lock = PidLock(PATH_PIDLOCK, nonblock=True) try: lock.lock() except lock.Locked: fatal("a previous backup is still in progress") if conf.s3_parallel_uploads > 1 and conf.s3_parallel_uploads > (conf.volsize / 5): warn("s3-parallel-uploads > volsize / 5 (minimum upload chunk is 5MB)") if not raw_upload_path: try: update_profile(conf.force_profile) except hub.Backups.NotInitialized, e: fatal("you need a profile to backup, run tklbam-init first") credentials = None if not conf.address and not dump_path: try: hb = hub_backups() except hub.Backups.NotInitialized, e: fatal(str(e) + "\n" + "tip: you can still use tklbam-backup with --dump or --address") try: registry.credentials = hb.get_credentials() except hb.Error, e: # asking for get_credentials() might fail if the hub is down.