From 5461dec55cf4cfe3fae67fafa3a41d9c0958d02e Mon Sep 17 00:00:00 2001 From: Florian Charlaix Date: Wed, 19 Oct 2022 13:35:36 +0200 Subject: [PATCH] Use account_id instead of access_key for bucket names and trim it trim to 50 --- .gitignore | 2 ++ BackupPC_archiveHost_b2.py | 2 +- backup-manager.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) mode change 100755 => 100644 BackupPC_archiveHost_b2.py diff --git a/.gitignore b/.gitignore index e9d6025..420d750 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ /secrets.py *.pyc /.venv/ +/venv/ +/test.py diff --git a/BackupPC_archiveHost_b2.py b/BackupPC_archiveHost_b2.py old mode 100755 new mode 100644 index fb6e154..4c7d7cb --- a/BackupPC_archiveHost_b2.py +++ b/BackupPC_archiveHost_b2.py @@ -212,7 +212,7 @@ def open_b2(access_key: str, shared_key: str, host: str) -> Bucket: :return: The host B2 bucket """ b2_api.authorize_account("production", access_key, shared_key) - my_bucket_name = f"{access_key}-bckpc-{host.replace('.', '-')}".lower() + my_bucket_name = f"{b2_api.account_info._account_id}-bckpc-{host.replace('.', '-')}".lower()[:50] lifecycle_rules = [{ 'daysFromHidingToDeleting': 1, 'daysFromUploadingToHiding': None, diff --git a/backup-manager.py b/backup-manager.py index c752c3e..3950c71 100644 --- a/backup-manager.py +++ b/backup-manager.py @@ -51,7 +51,7 @@ class BackupManager: self._backups = None def _generate_backup_buckets(self) -> [Bucket]: - bucket_prefix = f"{self._access_key}-bckpc-".lower() + bucket_prefix = f"{self._connection.account_info._account_id}-bckpc-".lower() buckets = self._connection.list_buckets() self._buckets = []