gcloud init
gsutil ls # shows buckets
gsutil ls gs://mybucket
# Upload to bucket
gsutil cp localfile gs://mybucket # copy
gsutil rsync -r -x ".git/*" . gs://BUCKET_NAME/
# -r recursive copy
# -x exclude files in the .git folder
# Set bucket to public-read
gsutil -m acl set -R -a public-read gs://BUCKET_NAME
# -m multithreaded
# -R recursive
# -a all object versions
# Version control
## Get status of versions ("Suspended" = not enabled, "Enabled")
gsutil versioning get gs://BUCKET_NAME/
gsutil versioning set on gs://BUCKET_NAME/
## List versions of the file
gsutil ls -al gs://BUCKET_NAME/myfile
$ gsutil ls -la gs://adam1/test.txt
3 2019-10-15T14:15:24Z gs://adam1/test.txt#1571148924339107 metageneration=1
6 2019-10-15T14:17:25Z gs://adam1/test.txt#1571149045157341 metageneration=1
TOTAL: 2 objects, 9 bytes (9 B)
# Delete bucket (the whole bucket, not just the files!)
gsutil rm -r gs://[BUCKET_NAME]
Cloud CDN https://cloud.google.com/cdn/ https://cloud.google.com/cdn/pricing
costs slightly more than regional bucket storage, but less than multi-regional. On the whole, more cost effective for a world-wide deployment
Add to GCP id=persistentdisks
Prefer Cloud Storage, unless you need an actual file system!
must be attached to a VM
compute engine - create a VM
ssh install apache http server cd /var/www/html
under disks - has a “standard persistent disk”, in same zone as the VM
https://cloud.google.com/compute/docs/disks/create-snapshots - snapshot a disk - on a schedule - stored in cloud storage - regional or multi-regional - create disk based on snapshot
- uses:
- backup a persistent disk
- move a disk to another region or zone
- make a persistent disk larger - https://cloud.google.com/compute/docs/disks/restore-and-delete-snapshots#restoresnapshotlargersize