From 85715fd61ed24685562e06466ddf4d72edc5def1 Mon Sep 17 00:00:00 2001 From: Stu Tomlinson Date: Wed, 28 Sep 2022 18:01:46 +0100 Subject: [PATCH] Fix restore sorting Sort in reverse to restore from latest backup instead of earliest --- scripts/backup-restore-s3.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/backup-restore-s3.py b/scripts/backup-restore-s3.py index cbf5b00..c051a2d 100644 --- a/scripts/backup-restore-s3.py +++ b/scripts/backup-restore-s3.py @@ -186,8 +186,8 @@ def restore(tsm, bucket_name, s3_prefix): # Sort both lists based on last updated date def sort_key(obj): return obj.get("LastModified") - tsbaks.sort(key=sort_key) - settings.sort(key=sort_key) + tsbaks.sort(key=sort_key, reverse=True) + settings.sort(key=sort_key, reverse=True) # Get an S3 resource reference s3_resource = boto3.resource('s3') @@ -259,4 +259,4 @@ def main(): # Find the latest backup in S3 and use TSM to restore from it status = restore(tsm=tsm, bucket_name=s3_bucket, s3_prefix=s3_prefix) -main() \ No newline at end of file +main()