output filename can't be specified manually

This commit is contained in:
missytake 2024-07-14 02:25:59 +02:00
parent a38d1d327f
commit 9c30736aa0
Signed by: missytake
GPG key ID: 04CC6658320518DF

View file

@ -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__":