From 9c30736aa05164c313f2ff23d3b6ca94103265a1 Mon Sep 17 00:00:00 2001 From: missytake Date: Sun, 14 Jul 2024 02:25:59 +0200 Subject: [PATCH] output filename can't be specified manually --- backup_dc_from_db_cli/cli.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/backup_dc_from_db_cli/cli.py b/backup_dc_from_db_cli/cli.py index ae28316..75fbd55 100644 --- a/backup_dc_from_db_cli/cli.py +++ b/backup_dc_from_db_cli/cli.py @@ -7,13 +7,14 @@ import sys from deltachat_rpc_client import DeltaChat, Rpc def main(): + homedir = default=os.getenv("HOME", ".") parser = argparse.ArgumentParser() parser.add_argument( - "--db_path", type=str, default=os.getenv("HOME", ".") + "/.config/DeltaChat/accounts", + "--db_path", type=str, homedir + "/.config/DeltaChat/accounts", help="Path to DeltaChat directory", ) parser.add_argument("--account", type=str, help="email address of the account to backup") - parser.add_argument("--output", type=str, help="output file name") + parser.add_argument("--output_dir", default=homedir, type=str, help="output directory") parser.add_argument( "--passphrase", type=str, default=os.environ.get("DC_BACKUP_PASSPHRASE", ""), help="passphrase to encrypt the backup file. environment variable: DC_BACKUP_PASSPHRASE" @@ -44,19 +45,16 @@ def main(): break else: print(f"{i}: {addr}") + i += 1 else: try: - account = accounts[int(input("\nWhich account do you want to backup?"))] + account = accounts[int(input("\nWhich account do you want to backup? "))] except: import pdb; pdb.set_trace() - if args.output: - output_filename = args.output - else: - timestamp = datetime.datetime.today().isoformat()[:10] - i = 0 - output_filename = f"delta-chat-backup-{timestamp}-{i}-{account.get_config('addr')}.tar" - account.export_backup(output_filename, passphrase=args.passphrase) + print("Exporting backup...") + account.export_backup(args.output_dir, passphrase=args.passphrase) + print(f"Done. Backup written to {args.output_dir} directory") if __name__ == "__main__":