Lifecycle and archiving
Associate Data Practitioner · Lesson 14 of 16 · 1:40:52
YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗
Learning with these videos? Subscribe for new courses and exam-style questions.
Subscribe on YouTube (opens in a new tab)In this lesson
Prepare for the Google Cloud Associate Data Practitioner exam, on the official exam guide. In this lesson: Cloud Storage classes, Autoclass and lifecycle rules, table and partition expiration in BigQuery, long-term storage, and archiving and retention with retention policies and Bucket Lock. Includes three original practice questions, with Cymbal Energy, a fictional electricity and gas supplier, as the example.
Study notes
The text of this lesson, to read at your own pace. Information as of November 2026.
Keeping everything, forever
Cymbal Energy keeps every reading it has ever received: raw files in Cloud Storage, and years of tables in BigQuery. Billing records must be kept for seven years, but raw files older than a few months are almost never read. And the storage bill grows every single month.
Cloud Storage classes
Cloud Storage offers four storage classes, all with fast access, but with different costs. Standard suits data that is read often, like this week's meter files. Nearline suits data that is read about once a month, with a minimum storage duration of thirty days, and Coldline suits data that is read about once a quarter, with ninety days. Archive suits data that is read less than once a year, like records kept for compliance, with a minimum of three hundred sixty-five days. The colder the class, the lower the cost to store the data, but the higher the cost to read it, so choose the class from how often the data is read.
Autoclass and lifecycle rules
When access patterns are hard to predict, Autoclass moves each object to a colder class when nobody reads it, and back to Standard when someone does. When the pattern is known, lifecycle rules act on the objects that match conditions, like their age, their storage class, or a name prefix. A rule can change the storage class, for example to Coldline after ninety days, or delete objects, for example raw files after one year, and a delete action wins over a class change. The rules run automatically, so unnecessary data disappears, and the storage bill stops growing.
Expiration in BigQuery
BigQuery has its own way to remove unnecessary data: expiration. A table can have an expiration time, and a dataset can set a default table expiration, so that every new table in it is deleted after, say, thirty days, which suits staging and temporary tables. In a partitioned table, a partition expiration deletes each old partition on its own, like daily partitions of raw readings older than two years, while the table stays. And a table or a partition that has not been modified for ninety consecutive days moves to long-term storage, at a lower rate, with no loss of performance.
Archiving and retention
Archiving keeps data that is rarely read, at the lowest cost, for as long as the business or the law requires. In Cloud Storage, the Archive class fits records that are read less than once a year, and it still returns them in milliseconds, with no restore step to wait for. A retention policy prevents objects from being deleted or replaced before a set period, and Bucket Lock makes that policy permanent: the period can be increased, but never reduced or removed. In BigQuery, long-term storage already lowers the cost of tables that nobody changes, and a table can also be exported to Cloud Storage, and kept in a cold class.
Recap
Let's recap. Standard, Nearline, Coldline, and Archive trade a lower storage cost for a higher cost to read, with minimums of thirty, ninety, and three hundred sixty-five days. Autoclass moves objects by how they are used, and lifecycle rules change classes or delete objects by age or other conditions. In BigQuery, table, default, and partition expirations delete data automatically. Untouched tables move to long-term storage after ninety days. And for records that must be kept, the Archive class and a retention policy locked with Bucket Lock keep them safe and cheap.
Quick checks for this lesson
The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.
Raw meter files are read often during their first month, then almost never, and must be deleted after two years. What is the most cost-effective setup, with no manual work?
- Rules: Coldline after a month, delete at two years
- Keep every file in Standard storage
- Put every file in Archive as soon as it lands
- Delete old files by hand every month
Show the answer
Rules: Coldline after a month, delete at two years
Lifecycle rules move the files to a colder class after the first month, and delete them after two years, automatically. “Keep every file in Standard storage” would pay the highest storage cost for files that nobody reads. “Put every file in Archive as soon as it lands” would charge more to read the files during the first month, when they are read often. And “Delete old files by hand every month” would rely on manual work, which is easy to forget.
The daily partitions of a raw readings table must be kept for 400 days, then removed automatically, while the table keeps receiving new data. What should be set?
- A table expiration of 400 days
- A default table expiration on the dataset
- A partition expiration of 400 days
- A scheduled query that drops the table
Show the answer
A partition expiration of 400 days
A partition expiration removes each daily partition after four hundred days, and the table keeps receiving new data. “A table expiration of 400 days” would delete the whole table, with all its partitions. “A default table expiration on the dataset” only applies to new tables in the dataset, and would also delete whole tables. And “A scheduled query that drops the table” would delete the whole table too, with a job to maintain.
Billing records must be kept unchanged for seven years, and nobody, not even an administrator, may delete them earlier. They might be read once in that time. What fits?
- Standard storage with object versioning
- Nearline with a delete rule after seven years
- A BigQuery table with a default expiration
- Archive class, with a locked retention policy
Show the answer
Archive class, with a locked retention policy
The Archive class keeps records that are rarely read at the lowest cost, and a locked retention policy stops anyone from deleting them early. “Standard storage with object versioning” would cost the most for data that is almost never read, and its versions can still be deleted. “Nearline with a delete rule after seven years” would still let someone delete the records before seven years. And “A BigQuery table with a default expiration” only deletes data, but nothing stops an earlier deletion.