From b2c94cc8eafb2ce1c0e8f286f5fe64b9ec15bed6 Mon Sep 17 00:00:00 2001 From: Andrew Schleifer Date: Fri, 12 Jun 2020 02:55:50 +0000 Subject: [PATCH] FIX: do not migrate backups in the new prefix --- lib/backup_restore/s3_backup_store.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/backup_restore/s3_backup_store.rb b/lib/backup_restore/s3_backup_store.rb index 108cb661ba7..359167b97c5 100644 --- a/lib/backup_restore/s3_backup_store.rb +++ b/lib/backup_restore/s3_backup_store.rb @@ -53,9 +53,11 @@ module BackupRestore def vacate_legacy_prefix legacy_s3_helper = S3Helper.new(s3_bucket_name_with_legacy_prefix, '', @s3_options.clone) - legacy_keys = legacy_s3_helper.list.map { |o| o.key } + bucket, prefix = s3_bucket_name_with_prefix.split('/', 2) + legacy_keys = legacy_s3_helper.list + .reject { |o| o.key.starts_with? prefix } + .map { |o| o.key } legacy_keys.each do |legacy_key| - bucket, prefix = s3_bucket_name_with_prefix.split('/', 2) @s3_helper.s3_client.copy_object({ copy_source: File.join(bucket, legacy_key), bucket: bucket,