Skip to main content

Utility script to restore files on AWS S3 that have GLACIER storage class

Project description

AWS S3 Glacier Restore

Utility script to restore files on AWS S3 that have GLACIER storage class.

Features at a glance

  • Calculates exact costs before restore
  • Multithreaded API requests significantly reduce restore time
  • Can check if all files for given prefix are already restored or not.

Installation and Upgrade

aws-s3-glacier-restore is developed in Python and uses pip.

The easiest way to install/upgrade s3select is to use pip in a virtualenv:

$ pip install -U aws-s3-glacier-restore

or, if you are not installing in a virtualenv, to install/upgrade globally:

$ sudo pip install -U aws-s3-glacier-restore

or for your user:

$ pip install --user -U aws-s3-glacier-restore

Authentication

aws-s3-glacier-restore uses the same authentication and endpoint configuration as aws-cli. If aws command is working on your machine, there is no need for any additional configuration.

Example usage

First get some help:

$ aws-s3-glacier-restore -h
usage: aws-s3-glacier-restore [-h] [-p PREFIX] [-i INPUT_FILE]
                              [-d DAYS_TO_KEEP] [-D DESTINATION_BUCKET]
                              [-t THREADS] [-s] [--profile PROFILE]

Utility script to restore files on AWS S3 that have GLACIER storage class

optional arguments:
  -h, --help            show this help message and exit
  -p PREFIX, --prefix PREFIX
                        S3 prefix URL to restore
  -i INPUT_FILE, --input_file INPUT_FILE
                        Input file containing all s3 paths to restore
  -d DAYS_TO_KEEP, --days_to_keep DAYS_TO_KEEP
                        How many days to keep restored files
  -D DESTINATION_BUCKET, --destination_bucket DESTINATION_BUCKET
                        Restore to this bucket instead of to original bucket
                        while preserving same path structure as in original
                        bucket. This is useful if you don't know for how long
                        you'll need restored files. Once you don't need them
                        you can delete them from destination bucket.
  -t THREADS, --threads THREADS
                        Number of threads to use. Default=40
  -s, --status_print    Just print status of files and how many of them are in
                        glacier and how many of them are restored already
  --profile PROFILE     Use a specific AWS profile from your credential file.

Then full run might look like this:

$ aws-s3-glacier-restore -p s3://test-restore-bucket/backup2/image_1503789115/part-r-0003 -d 2

Getting a listing of the files to restore... Done

About to restore 18.72GB in 10 files

Restore will cost us:
1) Expedited tier: $0.66
2) Standard tier:  $0.19
3) Bulk tier:      $0.05
Keeping files on S3 will cost: 0.02 per day

Press number in front of an option you wish or any other key to exit: 3
Starting restore using Bulk tier... Restoring backup2/image_1503789115/part-r-00030.gz
Restoring backup2/image_1503789115/part-r-00031.gz
Restoring backup2/image_1503789115/part-r-00032.gz
Restoring backup2/image_1503789115/part-r-00034.gz
Restoring backup2/image_1503789115/part-r-00036.gz
Restoring backup2/image_1503789115/part-r-00038.gz
Restoring backup2/image_1503789115/part-r-00033.gz
Restoring backup2/image_1503789115/part-r-00037.gz
Restoring backup2/image_1503789115/part-r-00035.gz
Restoring backup2/image_1503789115/part-r-00039.gz
Done
Time elapsed: 2s

Parameter --days_to_keep (-d) specifies how long files will be accessible as regular files over S3. In case you have finished with files earlier than expected or want to extend the amount of days they are kept available, you can run the same command, but this time with modified "-d" parameter. If you specify "-d 1" this will signal that files should be archived back as soon as possible (usually happens within one day):

$ aws-s3-glacier-restore -p s3://test-restore-bucket/backup2/image_1503789115/part-r-0003 -d 0

If you want to check restore status of files you can use -s switch:

$ aws-s3-glacier-restore -p s3://test-restore-bucket/archives/cars/GlacierImageArchive_2017_10-00000001-r-0009 -s
Getting a listing of the files... Done

Object s3://test-restore-bucket/archives/cars/GlacierImageArchive_2017_10-00000001-r-00091 is being restored
Object s3://test-restore-bucket/archives/cars/GlacierImageArchive_2017_10-00000001-r-00092 is in Glacier and not being restored
Object s3://test-restore-bucket/archives/cars/GlacierImageArchive_2017_10-00000001-r-00093 is in Glacier and not being restored
Object s3://test-restore-bucket/archives/cars/GlacierImageArchive_2017_10-00000001-r-00095 is in Glacier and not being restored
Object s3://test-restore-bucket/archives/cars/GlacierImageArchive_2017_10-00000001-r-00094 is in Glacier and not being restored
Object s3://test-restore-bucket/archives/cars/GlacierImageArchive_2017_10-00000001-r-00090 is restored until Fri, 19 Oct 2018 00:00:00 GMT
Object s3://test-restore-bucket/archives/cars/GlacierImageArchive_2017_10-00000001-r-00098 is restored until Fri, 19 Oct 2018 00:00:00 GMT
Object s3://test-restore-bucket/archives/cars/GlacierImageArchive_2017_10-00000001-r-00096 is restored until Mon, 24 Sep 2018 00:00:00 GMT
Object s3://test-restore-bucket/archives/cars/GlacierImageArchive_2017_10-00000001-r-00099 is in Glacier and not being restored
Object s3://test-restore-bucket/archives/cars/GlacierImageArchive_2017_10-00000001-r-00097 is in Glacier and not being restored
Restored count: 3/10

License

Distributed under the MIT license. See LICENSE for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aws-s3-glacier-restore-0.0.3.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aws_s3_glacier_restore-0.0.3-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file aws-s3-glacier-restore-0.0.3.tar.gz.

File metadata

  • Download URL: aws-s3-glacier-restore-0.0.3.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.16

File hashes

Hashes for aws-s3-glacier-restore-0.0.3.tar.gz
Algorithm Hash digest
SHA256 cea4cf5f03de074b3fe8ce3e6f58d536140ca843900fdd541ddff2842ae5cceb
MD5 3a51e8d08f354215cff5fec53d0d7633
BLAKE2b-256 ff6a7c1b21f433905a1698427dd2d57a9293aa066c4a30670ad72d217347b459

See more details on using hashes here.

File details

Details for the file aws_s3_glacier_restore-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: aws_s3_glacier_restore-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.16

File hashes

Hashes for aws_s3_glacier_restore-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fb096a6fdf9951a9379ad701a1edde7befef010a4b4f608776d9a8369373470d
MD5 adf7803e5f1df29b7fd5438f12a22253
BLAKE2b-256 61fd56c467b9ffa8a89549cd54e04428c160301c8a94657b2867dbf7991e7210

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page