
GCSToGCSOperator
GoogleCopies objects from a bucket to another, with renaming if requested.
Access Instructions
Install the Google provider package into your Airflow environment.
Import the module into your DAG file and instantiate it with your desired params.
Parameters
Documentation
Copies objects from a bucket to another, with renaming if requested.
See also
For more information on how to use this operator, take a look at the guide: GCSToGCSOperator
The following Operator would copy a single file named sales/sales-2017/january.avro in the data bucket to the file named copied_sales/2017/january-backup.avro in the data_backup bucket
copy_single_file = GCSToGCSOperator(task_id='copy_single_file',source_bucket='data',source_objects=['sales/sales-2017/january.avro'],destination_bucket='data_backup',destination_object='copied_sales/2017/january-backup.avro',gcp_conn_id=google_cloud_conn_id)
The following Operator would copy all the Avro files from sales/sales-2017 folder (i.e. with names starting with that prefix) in data bucket to the copied_sales/2017 folder in the data_backup bucket.
copy_files = GCSToGCSOperator(task_id='copy_files',source_bucket='data',source_objects=['sales/sales-2017'],destination_bucket='data_backup',destination_object='copied_sales/2017/',delimiter='.avro'gcp_conn_id=google_cloud_conn_id)Or ::copy_files = GCSToGCSOperator(task_id='copy_files',source_bucket='data',source_object='sales/sales-2017/*.avro',destination_bucket='data_backup',destination_object='copied_sales/2017/',gcp_conn_id=google_cloud_conn_id)
The following Operator would move all the Avro files from sales/sales-2017 folder (i.e. with names starting with that prefix) in data bucket to the same folder in the data_backup bucket, deleting the original files in the process.
move_files = GCSToGCSOperator(task_id='move_files',source_bucket='data',source_object='sales/sales-2017/*.avro',destination_bucket='data_backup',move_object=True,gcp_conn_id=google_cloud_conn_id)
- The following Operator would move all the Avro files from
sales/sales-2019 and
sales/sales-2020` folder in ``databucket to the same folder in thedata_backupbucket, deleting the original files in the process.move_files = GCSToGCSOperator(task_id='move_files',source_bucket='data',source_objects=['sales/sales-2019/*.avro', 'sales/sales-2020'],destination_bucket='data_backup',delimiter='.avro',move_object=True,gcp_conn_id=google_cloud_conn_id)