The Hidden Blog

As it turns out, I do have a hostname.

Cleaning up Amazon Glacier

Published on Nov 15, 2025

I've switched all my backups to Backblaze a while ago but I was pushing back the task of removing the old backups from Amazon Glacier. These were done through Arq Backup a while ago, from a different machine.

I had a monthly reminder for that task (The Amazon billing notification) so I finally set out to do that, dug up my old credentials and logged in. To my surprise I realized that you can't just delete the archive via the Amazon interface, even if there's a "Delete" button.

You also can't just delete it through the aws command line tools. You have to write custom code to generate a list of files (It's an async job, that takes ~4 hours), then delete them one by one (Following strict rate limitings from Amazon's side) and then 24 hours later the count on Amazon will update and you can finally use the "Delete" button on the empty archive in the interface.

There's many projects and scripts online to do that already but they didn't immediately work for me, so I just vibe coded my own which ran over night and finished successfully.

Maybe it's helpful for someone else too.

Step 1

Create an inventory of files:

   aws glacier initiate-job \
     --job-parameters '{"Type": "inventory-retrieval"}' \
     --account-id 1234 \
     --region eu-west-1 \
     --vault-name arq_123

You can check the progress with the following command, but expect it to take up to 4 hours.

aws glacier list-jobs \
  --account-id 123 \
  --region eu-west-1 \
  --vault-name arq_123

Step 2

Download the list of files in the inventory, once above tells you the job is finished.

aws glacier get-job-output \
  --account-id 534475282219 \
  --region eu-west-1 \
  --vault-name arq_123 \
  --job-id YOUR_JOB_ID \
  output.json

Then run the following Go script: https://gist.github.com/dewey/c402354c33e31cdd6e1f53d5a9e82f05

The output looks like the following, make sure you are logged into aws in your command line through something like: aws sts get-caller-identity.

Step 3

After 24 hours this should be reflected in the AWS interface and you should be able to delete the bucket.

~/m/g/d/aws-glacier-cleanup ❯❯❯ ./glacier-cleanup -account-id 123 -region eu-west-1 -vault-name arq_123 -input output-archive-ids.txt
2025/11/14 22:54:39 Starting AWS Glacier cleanup at 2025-11-14T22:54:39+01:00
2025/11/14 22:54:39 Account ID: 123, Region: eu-west-1, Vault: arq_123
2025/11/14 22:54:39 Using existing archive ID list from output-archive-ids.txt
2025/11/14 22:54:39 Total archives to delete: 756033
2025/11/14 22:54:39 Archives already deleted: 43965
2025/11/14 22:54:39 Archives remaining: 712068
2025/11/14 23:30:48 Progress: 35603/712068 deleted, 0 failed (5.0% complete) - 2025-11-14T23:30:48+01:00
2025/11/15 00:07:21 Progress: 71206/712068 deleted, 0 failed (10.0% complete) - 2025-11-15T00:07:21+01:00
2025/11/15 00:43:12 Progress: 106809/712068 deleted, 0 failed (15.0% complete) - 2025-11-15T00:43:12+01:00
2025/11/15 01:20:38 Progress: 142412/712068 deleted, 0 failed (20.0% complete) - 2025-11-15T01:20:38+01:00
2025/11/15 01:57:09 Progress: 178015/712068 deleted, 0 failed (25.0% complete) - 2025-11-15T01:57:09+01:00
2025/11/15 02:33:46 Progress: 213618/712068 deleted, 0 failed (30.0% complete) - 2025-11-15T02:33:46+01:00
2025/11/15 03:10:03 Progress: 249221/712068 deleted, 0 failed (35.0% complete) - 2025-11-15T03:10:03+01:00
2025/11/15 03:46:19 Progress: 284824/712068 deleted, 0 failed (40.0% complete) - 2025-11-15T03:46:19+01:00
2025/11/15 04:23:31 Progress: 320427/712068 deleted, 0 failed (45.0% complete) - 2025-11-15T04:23:31+01:00
2025/11/15 05:00:23 Progress: 356030/712068 deleted, 0 failed (50.0% complete) - 2025-11-15T05:00:23+01:00
2025/11/15 05:37:04 Progress: 391633/712068 deleted, 0 failed (55.0% complete) - 2025-11-15T05:37:04+01:00
2025/11/15 06:14:31 Progress: 427236/712068 deleted, 0 failed (60.0% complete) - 2025-11-15T06:14:31+01:00
2025/11/15 06:52:02 Progress: 462839/712068 deleted, 0 failed (65.0% complete) - 2025-11-15T06:52:02+01:00
2025/11/15 07:29:00 Progress: 498442/712068 deleted, 0 failed (70.0% complete) - 2025-11-15T07:29:00+01:00
2025/11/15 08:05:51 Progress: 534045/712068 deleted, 0 failed (75.0% complete) - 2025-11-15T08:05:51+01:00
2025/11/15 08:43:49 Progress: 569648/712068 deleted, 0 failed (80.0% complete) - 2025-11-15T08:43:49+01:00
2025/11/15 09:20:09 Progress: 605251/712068 deleted, 0 failed (85.0% complete) - 2025-11-15T09:20:09+01:00
2025/11/15 09:57:57 Progress: 640854/712068 deleted, 0 failed (90.0% complete) - 2025-11-15T09:57:57+01:00
2025/11/15 10:35:28 Progress: 676457/712068 deleted, 0 failed (95.0% complete) - 2025-11-15T10:35:28+01:00
2025/11/15 11:13:42 Progress: 712060/712068 deleted, 0 failed (100.0% complete) - 2025-11-15T11:13:42+01:00
2025/11/15 11:13:42 Finished at 2025-11-15T11:13:42+01:00
2025/11/15 11:13:42 Total deleted: 712068, Failed: 0
2025/11/15 11:13:42 Deleted archive IDs are in deleted-archive-ids.txt