GCP: How to backup and recover cloud source repository to a remote place?

834 Views Asked by At

I am creating a landing zone in GCP using Terraform. The IaC codes are stored in Cloud Source Repository. How do I setup a backup of these codes to a remote location and define a restoration process to the DR site. Kindly help, I am new to GCP

1

There are 1 best solutions below

0
Gianni Crivello On

You can clone the repo and store the Terraform code in a coldline or archive cloud storage bucket with gsutil or a client library. Cloud storage is great for this kinda thing. You'll also be able to add versioning and set up a cloud pub/sub to automate pushing to cloud storage when building with deployment manager for GCP.

GCP storage bucket docs: https://cloud.google.com/storage/docs/creating-buckets#storage-create-bucket-gsutil

GCP Pub/Sub docs if you wanna get a little fancier: https://cloud.google.com/pubsub/docs

Quick example using the cloud command console command line:

IN TERMINAL:

git clone <repo name>


gsutil mb [-b (on|off)] [-c <class>] [-l <location>] [-p <project>]
          [--retention <time>] [--pap <setting>]
          [--rpo (ASYNC_TURBO|DEFAULT)] gs://<bucket_name>...```

(make sure to set versioning for your bucket, it will help in DR)


gsutil mv <repo name> gs://<bucket_name>/path/to/location