1
votes

I just finished my 1 year free trial with Google Cloud Platform and I am now being billed.

When I set my first project up, it looks like I set it up as Multi-Regional. I would only use the Google Cloud Storage in the event of a catastrophic failure in my home where i lose data on both internal and external hard drives (ie. fire, etc) . I believe for this type of backup, I only need Coldline storage. I did change my project over to Coldline but it looks like it only changes new data, not the original stored data because I am still being charged for Multi-regional storage.

From what I understand, I have to change the Object Storage Class either by overwriting the data using "gsutil rewrite -s [STORAGE_CLASS] gs://[PATH_TO_OBJECT]" or by Object Lifestyle Management. I could not figure out how to do either, so I need help doing this (I am not even sure where to type these commands or which approach to use (I am not a programmer!!)).

I also saw in another post that my gsutil command needs to up to date 4.22 or higher. How do I check this?? I also saw in this post that the [PATH_TO_OBJECT] is My Bucket. I see a Project Name, Project ID, and Project number. Which of these (if any) are used in that field for My Bucket?

Thank you for any help

1

1 Answers

3
votes

I also saw in another post that my gsutil command needs to up to date 4.22 or higher. How do I check this??

Get the gsutil version:

gsutil version

Update the Cloud SDK which includes gsutil:

Windows: Open a command prompt with Administrator rights

gcloud components update

Linux:

gcloud components update

I see a Project Name, Project ID, and Project number. Which of these (if any) are used in that field for My Bucket.

Use the PROJECT_ID. To get a list of the projects that you have access to. This command will list each project.

gcloud projects list

To see which is your default project:

gcloud config list project

If the default project is blank or the wrong one, use the following command.

To set the default project:

gcloud config set project [PROJECT_ID]

From what I understand, I have to change the Object Storage Class either my overwriting the data

Assuming your bucket name is mybucket.

STEP 1: Change the default storage class for the bucket:

gsutil defstorageclass set coldline gs://mybucket

STEP 2: Change the storage class for each object manually. This is an option if you want to just select a few files.

gsutil rewrite -s coldline gs://mybucket/objectname

STEP 3: Verify the existing lifecycle policy. Change step 4 accordingly if an existing policy exists.

gsutil lifecycle get gs://mybucket

STEP 4: Change the lifecycle of the bucket. This policy will move all files older than 7 days to coldline storage.

POLICY (write to lifecycle.json):

{
    "lifecycle": {
        "rule": [
        {
            "action": {
                "type": "SetStorageClass",
                "storageClass": "COLDLINE"
            },
            "condition": {
                "age": 7,
                "matchesStorageClass": [
                    "MULTI_REGIONAL",
                    "STANDARD",
                    "DURABLE_REDUCED_AVAILABILITY"
                ]
            }
        }
        ]
    }
}

Command:

gsutil lifecycle set lifecycle.json gs://mybucket