You wrote that you needed "to copy all the files" to a local folder, assuming you wanted to copy the files recursively.
Because the files are kept in the Glacier storage class, you need to restore them from the Glacier archive first before you could copy them to your local folder, i.e. make the files available for retrieval for a specified number of days. After the restore completes, you can copy the files specifying the --force-glacier-transfer
parameter until the term that you have specified in days expire.
Unless you store the files in the "S3 Glacier Instant Retrieval" storage class, you should first restore the files (make them available for retrieval) so that --force-glacier-transfer
option would not fail. Therefore, the solution proposed at https://stackoverflow.com/a/62651252/6910868 does not apply to "S3 Glacier Deep Archive" storage class, for which you have to explicitly issue the restore-object
command and wait for its completion before you can copy files to your local folder.
However, the aws s3api restore-object
restores just one file and does not support recursive restore. The solution specified at https://stackoverflow.com/a/65925266/6910868 does not work for a recursive directory or when you have multiple files so that you wish to specify just the folder without listing all the files one by one.
As an alternative, instead of restoring the files by making them available for retrieval, you can change the object's storage class to Amazon S3 Standard. To do that, you can copy the files within S3, either by overwriting the existing files or by copying the files from one S3 location into another S3 location. In each case, you should specify the correct destination storage class.
If you just need to retrieve recursive files from the Glacier storage class without changing the storage class or making additional copies within S3, you can use the Perl script that lists the files recursively and then restores them from Glacier individually. This script may be used not only to initiate the restore using the specified restore tier, but to monitor the process as well.