0

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

Rutu Patel
  • 21
  • 1
  • 4
  • Source Repositories are Git Repositories. Look into git tools such as **git bundle create** and **git clone --mirror**. Invest the time to understand how git repos are stored on disk (the .git directory): https://www.youtube.com/watch?v=zwHZOPobpc4 Then there are third-party tools. This link might help you: https://cloud.google.com/source-repositories/docs/mirroring-a-github-repository – John Hanley Nov 19 '21 at 08:01

1 Answers1

1

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