Bird
Raised Fist0
GCPcloud~5 mins

Storage transfer service in GCP - Commands & Configuration

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Introduction
Moving large amounts of data between storage locations can be slow and error-prone. Storage Transfer Service helps you copy data quickly and reliably between cloud storage buckets or from on-premises to cloud storage.
When you want to copy files from one Google Cloud Storage bucket to another without downloading them locally.
When you need to migrate data from an on-premises server to Google Cloud Storage efficiently.
When you want to schedule regular backups of your cloud storage data to another location.
When you want to transfer data from Amazon S3 to Google Cloud Storage.
When you want to move large datasets without writing custom scripts or manual copying.
Config File - transfer-job.json
transfer-job.json
{
  "description": "Daily transfer from source bucket to destination bucket",
  "status": "ENABLED",
  "projectId": "example-project-123",
  "transferSpec": {
    "gcsDataSource": {
      "bucketName": "source-bucket-example"
    },
    "gcsDataSink": {
      "bucketName": "destination-bucket-example"
    },
    "objectConditions": {
      "minTimeElapsedSinceLastModification": "86400s"
    },
    "transferOptions": {
      "overwriteObjectsAlreadyExistingInSink": true
    }
  },
  "schedule": {
    "scheduleStartDate": {
      "year": 2024,
      "month": 6,
      "day": 1
    },
    "startTimeOfDay": {
      "hours": 2,
      "minutes": 0,
      "seconds": 0
    }
  }
}

This JSON file defines a transfer job that copies data daily from one Google Cloud Storage bucket to another.

  • description: A friendly name for the job.
  • status: Enables the job to run.
  • projectId: Your Google Cloud project ID.
  • transferSpec: Defines source and destination buckets and transfer options.
  • schedule: Sets the job to run daily at 2 AM starting June 1, 2024.
Commands
This command creates a new Storage Transfer Service job using the configuration in transfer-job.json.
Terminal
gcloud transfer jobs create transfer-job.json
Expected OutputExpected
Created transfer job: transferJobs/1234567890abcdef
Lists all transfer jobs in the specified project to verify the job was created.
Terminal
gcloud transfer jobs list --project=example-project-123
Expected OutputExpected
NAME DESCRIPTION STATUS transferJobs/1234567890abcdef Daily transfer from source bucket to destination bucket ENABLED
--project - Specifies the Google Cloud project to list jobs from
Shows recent transfer operations to check the status of running or completed transfers.
Terminal
gcloud transfer operations list --project=example-project-123
Expected OutputExpected
NAME STATUS transferOperations/abcdef1234567890 SUCCESS
--project - Specifies the Google Cloud project to list operations from
Key Concept

If you remember nothing else from this pattern, remember: Storage Transfer Service automates and schedules reliable data copying between cloud storage locations without manual downloads.

Common Mistakes
Using incorrect bucket names in the transfer job JSON.
The transfer job will fail because it cannot find the source or destination buckets.
Double-check bucket names exist and are spelled exactly as in your Google Cloud Storage.
Not enabling the transfer job status (leaving it DISABLED).
The job will be created but never run automatically.
Set the status field to ENABLED in the JSON configuration to activate the job.
Forgetting to specify the project ID when listing jobs or operations.
Commands will show no results or errors because they don't know which project to query.
Always include --project=your-project-id when running gcloud transfer commands.
Summary
Create a transfer job JSON file defining source, destination, schedule, and options.
Use gcloud transfer jobs create to create the job from the JSON file.
Verify the job exists with gcloud transfer jobs list and check transfer status with gcloud transfer operations list.

Practice

(1/5)
1. What is the primary purpose of the Google Cloud Storage Transfer Service?
easy
A. To move or copy data between different storage locations automatically
B. To create backups of virtual machines
C. To monitor network traffic between cloud services
D. To manage user permissions in Google Cloud

Solution

  1. Step 1: Understand the service function

    Storage Transfer Service is designed to move or copy data between storage locations like on-premises, AWS S3, or Google Cloud Storage.
  2. Step 2: Eliminate unrelated options

    Options B, C, and D describe different services unrelated to data transfer.
  3. Final Answer:

    To move or copy data between different storage locations automatically -> Option A
  4. Quick Check:

    Storage Transfer Service = Data movement [OK]
Hint: Remember: Transfer Service moves or copies data [OK]
Common Mistakes:
  • Confusing transfer service with backup or monitoring tools
  • Thinking it manages user permissions
  • Assuming it only works within Google Cloud
2. Which of the following is the correct way to specify a source in a Storage Transfer Service job configuration?
easy
A. "source": {"network": {"subnet": "default"}}
B. "source": {"vmInstance": {"name": "instance-1"}}
C. "source": {"gcsDataSource": {"bucketName": "my-source-bucket"}}
D. "source": {"sqlDatabase": {"dbName": "mydb"}}

Solution

  1. Step 1: Identify valid source types

    Storage Transfer Service supports sources like Google Cloud Storage buckets, AWS S3 buckets, or on-premises data.
  2. Step 2: Match correct JSON syntax for GCS source

    The correct syntax uses "gcsDataSource" with a "bucketName" field, as shown in "source": {"gcsDataSource": {"bucketName": "my-source-bucket"}}.
  3. Final Answer:

    "source": {"gcsDataSource": {"bucketName": "my-source-bucket"}} -> Option C
  4. Quick Check:

    Source config for GCS = "source": {"gcsDataSource": {"bucketName": "my-source-bucket"}} [OK]
Hint: Look for "gcsDataSource" with bucketName for GCS source [OK]
Common Mistakes:
  • Using unsupported source types like VM or SQL database
  • Incorrect JSON structure for source
  • Confusing source with destination fields
3. Given this Storage Transfer Service schedule configuration snippet:
{"schedule": {"scheduleStartDate": {"year": 2024, "month": 6, "day": 10}, "startTimeOfDay": {"hours": 3, "minutes": 0}}}

When will the transfer job start?
medium
A. At 3:00 AM on June 10, 2024
B. At 3:00 PM on June 10, 2024
C. At midnight on June 10, 2024
D. At 3:00 AM on June 9, 2024

Solution

  1. Step 1: Read the scheduleStartDate and startTimeOfDay

    The date is June 10, 2024, and the time is 3 hours and 0 minutes, which means 3:00 AM.
  2. Step 2: Confirm time format

    The time is in 24-hour format, so 3 means 3 AM, not PM.
  3. Final Answer:

    At 3:00 AM on June 10, 2024 -> Option A
  4. Quick Check:

    3 hours = 3 AM, date matches [OK]
Hint: Hours in 24-hour format; 3 means 3 AM [OK]
Common Mistakes:
  • Mistaking 3 for 3 PM instead of 3 AM
  • Ignoring the date and assuming current day
  • Confusing startTimeOfDay with duration
4. You wrote this Storage Transfer Service job configuration but the transfer never starts:
{"transferJob": {"status": "ENABLED", "schedule": {"scheduleStartDate": {"year": 2024, "month": 7, "day": 20}, "startTimeOfDay": {"hours": 25, "minutes": 0}}}}

What is the problem?
medium
A. The transferJob status should be DISABLED to start
B. The scheduleStartDate is in the past
C. The minutes value must be 30 or 60
D. The startTimeOfDay hours value is invalid; it must be between 0 and 23

Solution

  1. Step 1: Check startTimeOfDay values

    The hours field is set to 25, which is invalid because valid hours range from 0 to 23.
  2. Step 2: Validate other fields

    The scheduleStartDate is a future date, status is ENABLED which is correct, and minutes is 0 which is valid.
  3. Final Answer:

    The startTimeOfDay hours value is invalid; it must be between 0 and 23 -> Option D
  4. Quick Check:

    Hours must be 0-23, 25 is invalid [OK]
Hint: Hours must be 0-23; 25 is invalid [OK]
Common Mistakes:
  • Assuming status DISABLED starts the job
  • Thinking minutes must be 30 or 60
  • Ignoring invalid hour value
5. You want to transfer data daily from an AWS S3 bucket to a Google Cloud Storage bucket using Storage Transfer Service. Which combination of settings is required?
hard
A. Set GCS bucket as source, AWS S3 as destination, and schedule weekly
B. Set AWS S3 as source with access keys, GCS bucket as destination, and schedule daily
C. Use on-premises source with VPN, GCS bucket as destination, and schedule once
D. Set AWS S3 as source without credentials, GCS bucket as destination, and no schedule

Solution

  1. Step 1: Identify source and destination

    The source is AWS S3 bucket, which requires access keys for authentication. The destination is a Google Cloud Storage bucket.
  2. Step 2: Set schedule for daily transfers

    To transfer data daily, the schedule must be configured to run every day.
  3. Final Answer:

    Set AWS S3 as source with access keys, GCS bucket as destination, and schedule daily -> Option B
  4. Quick Check:

    AWS S3 source + credentials + daily schedule = Set AWS S3 as source with access keys, GCS bucket as destination, and schedule daily [OK]
Hint: AWS S3 needs keys; schedule daily for repeated transfers [OK]
Common Mistakes:
  • Forgetting AWS credentials
  • Reversing source and destination
  • Not setting a schedule for repeated transfers