Tim Andersson has proposed merging ~andersson123/autopkgtest-cloud:db-backup-add-checksum-to-filename into autopkgtest-cloud:master.
Requested reviews: Canonical's Ubuntu QA (canonical-ubuntu-qa) For more details, see: https://code.launchpad.net/~andersson123/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/462687 -- Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~andersson123/autopkgtest-cloud:db-backup-add-checksum-to-filename into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-web/webcontrol/db-backup b/charms/focal/autopkgtest-web/webcontrol/db-backup index 4ca6a20..259c561 100755 --- a/charms/focal/autopkgtest-web/webcontrol/db-backup +++ b/charms/focal/autopkgtest-web/webcontrol/db-backup @@ -12,6 +12,7 @@ import logging import os import shutil import sqlite3 +import hashlib import sys from pathlib import Path @@ -96,6 +97,12 @@ def create_container_if_it_doesnt_exist(swift_conn: swiftclient.Connection): ) +def get_db_backup_checksum(): + with open("%s.gz" % DB_BACKUP_PATH, "rb") as bkp_f: + md5 = hashlib.md5(bkp_f.read()).hexdigest() + return md5 + + def upload_backup_to_db( swift_conn: swiftclient.Connection, ) -> swiftclient.Connection: @@ -103,7 +110,8 @@ def upload_backup_to_db( Upload compressed database to swift storage under container db-backups """ now = datetime.datetime.utcnow().strftime("%Y/%m/%d/%H_%M_%S") - object_path = "%s/%s" % (now, DB_PATH.name + ".gz") + checksum = get_db_backup_checksum() + object_path = "%s/%s/%s" % (now, checksum, DB_PATH.name + ".gz") for retry in range(SWIFT_RETRIES): try: swift_conn.put_object(
-- Mailing list: https://launchpad.net/~canonical-ubuntu-qa Post to : canonical-ubuntu-qa@lists.launchpad.net Unsubscribe : https://launchpad.net/~canonical-ubuntu-qa More help : https://help.launchpad.net/ListHelp