1. Object versioning
    1. When enabled, deleted or overwritten objects are archived
    2. Enables retrieval of deleted or overwritten objects
    3. Object maintains name but assigned unique identifier number
    4. Enabled at bucket level
    5. Disabled by default
    6. If versioning is disabled, existing version remain but new ones not created
    7. No default limit on versions
    8. Versioning can increase bucket size and cost significantly
    9. Archived versions retain own ACL which may differ from live object ACL
    10. Actions
      1. List archived versions
      2. Restore archived versions to live state
      3. Permanently delete older versions
  2. Object lifecycle management
    1. Set Time to Live (TTL) on an object
    2. Archive/Delete older versions
    3. Downgrade storage classes
    4. Appled to bucket level
    5. Often used alongside object versioning, but not required
    6. Policies
      1. Downgrade the storage class of objects older than 365 days to cold storage
      2. Delete objects created before January 1, 2017
      3. Keep only the 3 most recent versions of each object in a bucket
      4. Implemented with Rules, Conditions and Actions
    7. Rules must have all conditions met before executing
    8. Actions only need one Rule to be met before being executed
  3. Lifecycle Management
    1. Set of rules that apply to current and future objects in a bucket
      1. Time to Live (TTL)
      2. Archiving older versions
      3. Downgrading storage
    2. Specified action is automatically performed when objects meets the criteria of rule
    3. Actions
      1. Delete live and/or archived objects. Cannot be undone
      2. Change the storage class of live and/or archived objects
      3. Applies to versioned and non-versioned objects
    4. Behavior
      1. At least one condition is required
      2. Asynchronous regular inspection on each bucket
      3. Does not rewrite an object when changing its storage class
  4. gsutil
    1. Operations
      1. Creating and deleting buckets
      2. Uploading, downloading and deleting objects
      3. Listing buckets and objects
      4. Moving, copying and renaming objects
      5. Editing object and bucket ACLs
    2. Commands
      1. gsutil cp file.txt gs://mybucket
      2. gsutil ls -a gs://mybucket
      3. gsutil -m cp -r gs://mybucket .
      4. gsutil help cp
      5. gsutil versioning get gs://<bucket>
      6. gsutil versioning set on gs://<bucket>
      7. gsutil ls gs://<bucket>/folder
      8. gsutil ls -r gs://<bucket>
      9. gsutil cp <file> gs://<bucket>
      10. gsutil lifecycle get gs://<bucket> > filename.json
      11. gsutil lifecycle set filename.json gs://<bucket>
      12. gsutil rm -r gs://<bucket>
      13. gsutil mb -l <location> -c <class> gs://<bucket>
      14. gsutil -m cp -r <files/directory> gs://<bucket>
      15. gsutil versioning set off gs://<bucket>
      16. gsutil -m rewrite -r -s NEARLINE gs://<bucket>/* (-m for parallel processing
      17. gsutil acl ch -d AllUsers:R gs://<bucket>/<object>
      18. gsutil acl ch -d AllUsers gs://<bucket>/<object>
      19. gsutil rm -r gs://<bucket>
  5. Bucket Lock
    1. Allows users to configure data retention policies for Cloud Storage bucket
    2. Policies govern how long objects in a bucket must be retained
    3. Data retention policies can be locked permanently, preventing delete or modification
    4. Used for Write Once Read Many (WORM) storage
    5. Prevents deletion of modification of data for a specified time period
    6. Helps meet compliance, legal and regulatory requirements for data retention
    7. Works with all tiers of Cloud Storage
    8. Lifecycle policies can be applied to automatically move locked data to colder storage classes
    9. Retention Policies
      1. A retention policy can be included when creating a new bucket
      2. Add a retention policy to an existing bucket
      3. Ensures objects cannot be deleted or overwitten until they reach the age defined in the policy
      4. Tracked by retention expiration time metadata
    10. Retention Period
      1. Measured in seconds
      2. Can be set in days, months or years
      3. Max is 100 years
    11. Retention Policy Locks
      1. Prevents the policy from ever being removed
      2. Prevents the retention period from ever being reduced
      3. Once retention policy is locked, bucket can't be deleted until objects have met the retention period
      4. Locking a retention policy is irreversible
      5. Project-wide lien is put in place by Object Storage
    12. Object Holds
      1. Metadata flags that are placed on individual objects
      2. Objects with holds cannot be deleted
      3. Event based holds can be used with retention policies to control retention based on events
      4. Temporary holds can be used for regulatory or legal investigation purposes
      5. Objects can have one, both or neither
    13. Compliance
      1. Can be used to comply with regulatory requirements
    14. Removal
      1. Locking a retention policy is irreverable
      2. Once locked, the entire bucket must be deleted in order to remove the retention policy
      3. All objects must be deleted from the bucket before the bucket can be deleted
      4. Objects can only be deleted if they have reached the retention period set by the retention policy
  6. Transfer
    1. Time
      1. By default gsutil transfers one file at a time
      2. Each transfer has an overhead which can affect performance
      3. Large files take a long time to transfer, even with sufficient bandwidth
      4. The smaller the file, the more the overhead affects the total transfer time
      5. Slice large files into smaller pieces (composite objects)
      6. Transfer multiple files at a time with multi-threading
      7. GCP re-assembles the pieces when the transfer is complete
      8. gsutil -m cp -r /my-local-dir gs://my-bucket
      9. gsutil -o GSUtil:parallel_composite_upload_threshold=150M cp ./my-large-fiule gs://my-bucket
      10. Do not use Nearline/Coldline storage class as this will result in a "modification" fee
    2. Performance
      1. Use "perfdiag" option in gsutil
      2. Diagnostic only. Does not optimize transfers
      3. Need to measure performance for standard and optimized transfers
      4. Test transfers, reading and deleting multiple test files of different sizes to GCS
      5. Adjust parameters for file size =, multi-threading,number of tests etc, to view results
      6. gsutil perfdiag gs://my-bucket