FIX: do not migrate backups in the new prefix

FIX: do not migrate backups in the new prefix

diff --git a/lib/backup_restore/s3_backup_store.rb b/lib/backup_restore/s3_backup_store.rb
index 108cb66..359167b 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,

GitHub sha: b2c94cc8

1 Like

This commit has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/vacatelegacyprefixbackups-job-stuck/154107/10