Moving files between Amazon S3 on a glacier and vice versa using software API

I am building a PHP based web application using Amazon S3 and glacier services.

Now I want to give users of the site the opportunity to use any file and make it an archive (means move the file from S3 to Glacier) and unarchive (means move the file from Glacier to S3).

I did some research and did not find a possible way to use the Amazon API.

PROBLEM

How can I move files between S3 and glacier using the API?

+6
source share
2 answers

You can use the Glacier API to upload a file to the Glacier repository, but I do not recommend it. The previous version of our request the ability to download an object ; when it is ready, you can download it. There is also an “hourly fee per hour” that comes into play if you request that objects load too fast. Amazon glacier prices are tricky.

Once the Glacier Storage Class object is no way to change it to Standard Storage Class. You must make a copy of the Standard Storage Class object and delete the Glacier object.

So, perhaps a simple solution to your problem:

  • Store data in 2 “folders” in S3, “standard” and “glacier”.
  • Establish a lifecycle policy to pop out all the objects in the glacier folder in the Glacier data warehouse as soon as possible.
  • If you want to move an object from the standard to the glacier, copy it to the glacier folder and delete the object in the standard folder (there is no "move" API there).
  • If you want to move an object from a glacier to a standard, execute a POST request to restore it ; when it is restored, copy it to the standard folder and delete it from the glacier folder.
+16
source

You can use the API to define lifecycle rules that archive files from Amazon S3 to the Amazon Glacier, and you can use the API to get a temporary copy of files archived to the glacier. However, you cannot use the API to tell Amazon S3 that certain files have been moved to the glacier.

There are two ways to use the Amazon Glacier:

  • Directly through the Glacier API, which allows you to upload / download archives to / from glacier storages.
  • Amazon S3 Lifecycle Guidelines that archive data from Amazon S3 into Amazon Glacier

Connecting directly through the Glacier API allows you to store archives for long-term storage, often used as a tape replacement. Data stored through the Glacier API must also be retrieved through the Glacier API. This is usually done with conventional enterprise backup software or even lightweight products such as Cloudberry Backup (Windows) or Arq (Mac).

Using Amazon S3 lifecycle rules allows you to store data in Amazon S3, and then define rules that determine when data should be archived for Glacier for long-term storage. For example, data can be archived 90 days after creation. Data transfer is governed by life cycle rules that operate on a daily basis. Rules can be set using the putBucketLifecycle API (available in the PHP SDK), but this only defines the rules — it is not possible to make an API call that tells S3 to archive specific files on Glacier.

Amazon S3 has a RestoreObject API (available in the PHP SDK) for restoring a temporary copy of data archived from the glacier back to S3. Please note that data recovery from the glacier takes 3-5 hours .

+4
source

Source: https://habr.com/ru/post/978603/


All Articles