Practice Test 2 | Google Cloud Certified Professional Cloud Architect | Dumps | Mock Test
You are creating a solution to remove backup files older than 90 days from your backup Cloud Storage bucket. You want to optimize ongoing Cloud Storage spending. What should you do?
A. Write a lifecycle management rule in XML and push it to the bucket with gsutil.
B. Schedule a cron script using gsutil ls -lr gs://backups/** to find and remove items older than 90 days.
C. Schedule a cron script using gsutil ls -1 gs://backups/** to find and remove items older than 90 days and schedule it with cron.
D. Write a lifecycle management rule in JSON and push it to the bucket with gsutil.
Correct Answer – D
Opion A – Write a lifecycle management rule in XML and push it to the bucket with gsutil: you can set lifecycle configuration for an existing bucket with a PUT API call request (NOT the “gsutil lifecycle” command!). You must include an XML document in the request body that contains the lifecycle configuration. https://cloud.google.com/storage/docs/xml-api/put-bucket-lifecycle#request_body_elements
B and C can be eliminated. They do the similar thing slightly different: write script listing object and get their timestamps
gsutil ls –[l or lr] gs://[BUCKET_NAME]/**
If an object’s age is older than 90 days, do deleting, then schedule a cron job for the recurring process.
However, gsutil ls -l/-lr does not list versioned objects. To list versioned object, need gsutil ls -a. Using this approach, versioned archives won’t be deleted.
There is a better, easier, and more consistent way to do this in Answer D
D (Correct answer) – Write a lifecycle management rule in JSON and push it to the bucket with gsutil.
To enable lifecycle management for a bucket: https://cloud.google.com/storage/docs/managing-lifecycles
· Create a .json file with the lifecycle configuration rules you would like to apply (see examples below).
· Use the lifecycle set command to apply the configuration
gsutil lifecycle set [LIFECYCLE_JSON-CONFIG_FILE] gs://[BUCKET_NAME]
The following lifecycle configuration JSON document specifies that all objects in this bucket that are more than 90 days old will be deleted automatically:
{
“rule”:
[
{
“action”: {“type”: “Delete”},
“condition”: {“age”: 90}
}
]
}
Comments are closed, but trackbacks and pingbacks are open.