You run the command gsutil cp -r ./localdir gs://my-bucket/backup/. What will be the result in the bucket?
Think about how gsutil cp -r handles directory structures when copying.
The -r flag copies directories recursively, preserving the directory name. So localdir becomes a folder inside backup/.
You want to make all objects in gs://my-bucket/data/ publicly readable using gsutil. Which command achieves this?
Consider the difference between ACLs and IAM policies in gsutil.
gsutil acl ch -u AllUsers:R gs://my-bucket/data/** uses the ** wildcard to recursively add read permission for all users on all objects matching the data/ prefix. The acl set public-read command replaces the ACL and is not recursive by default. IAM policies apply at the bucket level to all objects.
You need to upload 10 TB of data to a bucket quickly. Which gsutil option helps maximize upload speed?
Think about how gsutil can upload multiple files at once.
The -m flag enables parallel (multi-threaded/multi-processing) uploads, which speeds up large data transfers significantly.
You want to prevent accidental deletion of objects in your bucket using gsutil. Which feature should you enable?
Think about how to recover deleted objects.
Object Versioning keeps old versions of objects, so if deleted accidentally, you can restore them.
You want to keep a local directory and a bucket folder in sync, copying only changed files and deleting removed files in the bucket. Which gsutil command and flags achieve this?
Consider how to delete files in the destination that no longer exist in the source.
The gsutil rsync command with -d deletes extra files in the destination, and -r syncs recursively.