How to copy files from Google Cloud Storage bucket 1 to bucket 2 using gsutil while preserving ACLs


super eye

I'm planning to copy a single file on Google Cloud Storage from bucket 1 to bucket 2 while preserving ACLs (Access Control Lists) using gsutil.

The following command copies files, but does not copy ACL information:

gsutil cp -p rsync gs://bucket1/path/file gs://bucket2/path/file

How to copy files and ACLs at the same time?

Prabir down jacket
  • First, if we want to copy objects from one bucket to another with full ACLs, we must use fine-grained access control for both buckets.
  • If we use unified access control, then objects will have permissions based on the target bucket.
  • To learn more about ACLs for buckets and objects, you can visit this link .

Now to answer your question, if you have fine-grained access control on both buckets, the following command should do it.

gsutil cp -p  gs://source_bucket/file_name gs://destination_bucket/new_file_name 

  
  • You can find a reference to the above command at this link .

Related


cloud/gsutil to copy files from instance to bucket

Serpentine I've tried gsutil rsync/cp from inside the instance and it works. I'm looking for a way to run sync from my local machine using gcloud/gsutil cli. Is there a command like gcloud compute scp to sync from instance to bucket? [EDIT] I looked at the off

Copy files from S3 bucket to Google Cloud Storage

User 374374 Trying to ingest data from AWS S3 to Google Cloud Storage using Storage Transfer. I have the S3 bucket "Access Key ID" and "Secret Access Key" and I am able to copy from gsutil (from my laptop) but it throws permission errors from storage transfer.

Copy from Google Cloud Storage Bucket to S3 Bucket

D_usv I've set up an airflow workflow that receives some files from s3 to Google Cloud storage and then runs a workflow of sql queries to create new tables on Big Query. At the end of the workflow, I need to push the output of a final Big Query table to Google

Copy from Google Cloud Storage Bucket to S3 Bucket

D_usv I've set up an airflow workflow that receives some files from s3 to Google Cloud storage and then runs a workflow of sql queries to create new tables on Big Query. At the end of the workflow, I need to push the output of a final Big Query table to Google

Copy from Google Cloud Storage Bucket to S3 Bucket

D_usv I've set up an airflow workflow that receives some files from s3 to Google Cloud storage and then runs a workflow of sql queries to create new tables on Big Query. At the end of the workflow, I need to push the output of a final Big Query table to Google

Copy from Google Cloud Storage Bucket to S3 Bucket

D_usv I've set up an airflow workflow that receives some files from s3 to Google Cloud storage and then runs a workflow of sql queries to create new tables on Big Query. At the end of the workflow, I need to push the output of a final Big Query table to Google

Copy from Google Cloud Storage Bucket to S3 Bucket

D_usv I've set up an airflow workflow that receives some files from s3 to Google Cloud storage and then runs a workflow of sql queries to create new tables on Big Query. At the end of the workflow, I need to push the output of a final Big Query table to Google

Copy from Google Cloud Storage Bucket to S3 Bucket

D_usv I've set up an airflow workflow that receives some files from s3 to Google Cloud storage and then runs a workflow of sql queries to create new tables on Big Query. At the end of the workflow, I need to push the output of a final Big Query table to Google