|
| 1 | +# Transfer Service sample using Python |
| 2 | + |
| 3 | +This app creates two types of transfers using the Transfer Service tool. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +1. Set up a project on Google Developers Console. |
| 8 | + 1. Go to the [Developers Console](https://cloud.google.com/console) and create or select your project. |
| 9 | + You will need the project ID later. |
| 10 | +1. Within Developers Console, select APIs & auth > Credentials. |
| 11 | + 1. Add a new JSON key credential for a service account. |
| 12 | + 1. Set the environment variable GOOGLE_APPLICATION_CREDENTIALS to point to your JSON key. |
| 13 | +1. Add the Storage Transfer service account, [email protected] as an |
| 14 | + editor of your project. |
| 15 | +1. Set up gcloud for application default credentials. |
| 16 | + 1. `gcloud components update` |
| 17 | + 1. `gcloud auth login` |
| 18 | + 1. `gcloud config set project PROJECT_ID` |
| 19 | +1. Install [Google API Client Library for Python](https://developers.google.com/api-client-library/python/start/installation). |
| 20 | + |
| 21 | +## Transfer from Amazon S3 to Google Cloud Storage |
| 22 | + |
| 23 | +Creating a one-time transfer from Amazon S3 to Google Cloud Storage. |
| 24 | +1. Set up data sink. |
| 25 | + 1. Go to the Developers Console and create a bucket under Cloud Storage > Storage Browser. |
| 26 | +1. Set up data source. |
| 27 | + 1. Go to AWS Management Console and create a bucket. |
| 28 | + 1. Under Security Credentials, create an IAM User with access to the bucket. |
| 29 | + 1. Create an Access Key for the user. Note the Access Key ID and Secret Access Key. |
| 30 | +1. In aws_request.py, fill in the Transfer Job JSON template with relevant values. |
| 31 | +1. Run with `python aws_request.py` |
| 32 | + 1. Note the job ID in the returned Transfer Job. |
| 33 | + |
| 34 | +## Transfer data from a standard Cloud Storage bucket to a Cloud Storage Nearline bucket |
| 35 | + |
| 36 | +Creating a daily transfer from a standard Cloud Storage bucket to a Cloud Storage Nearline |
| 37 | +bucket for files untouched for 30 days. |
| 38 | +1. Set up data sink. |
| 39 | + 1. Go to the Developers Console and create a bucket under Cloud Storage > Storage Browser. |
| 40 | + 1. Select Nearline for Storage Class. |
| 41 | +1. Set up data source. |
| 42 | + 1. Go to the Developers Console and create a bucket under Cloud Storage > Storage Browser. |
| 43 | +1. In nearline_request.py, fill in the Transfer Job JSON template with relevant values. |
| 44 | +1. Run with `python nearline_request.py` |
| 45 | + 1. Note the job ID in the returned Transfer Job. |
| 46 | + |
| 47 | +## Checking the status of a transfer |
| 48 | + |
| 49 | +1. In transfer_check.py, fill in the Transfer Job JSON template with relevant values. |
| 50 | + Use the Job Name you recorded earlier. |
| 51 | +1. Run with `python transfer_check.py` |
0 commit comments