FreeSBC:Uploading backups to Google Cloud Bucket
In this tutorial, we are going to help you use Google gsutil to access Google Bucket. We will do this so you can easily build your own scripts for backing up your files to the cloud and easily retrieve them as needed.
Install and Configure Google Cloud SDK
Cloud SDK is available in package format for installation on Red Hat Enterprise Linux 7, Red Hat Enterprise Linux 8, Fedora 32, and CentOS 7 systems. This package contains the gcloud, gcloud alpha, gcloud beta, gsutil, and bq commands.
1. Update repository with Cloud SDK repo information:
sudo tee -a /etc/yum.repos.d/google-cloud-sdk.repo << EOM [google-cloud-sdk] name=Google Cloud SDK baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el7-x86_64 enabled=1 gpgcheck=1 repo_gpgcheck=1 gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg EOM
2. Install the Cloud SDK:
yum install google-cloud-sdk
Initializing the Cloud SDK
Use the gcloud init command to perform several common Cloud SDK setup tasks. These include authorizing the Cloud SDK tools to access Google Cloud using your user account credentials and setting up the default configuration.
To initialize the Cloud SDK:
1. Run the following at a command prompt:
gcloud init
2. Accept the option to log in using your Google user account:
To continue, you must log in. Would you like to log in (Y/n)? Y
3. In your browser, log in to your Google user account when prompted and click Allow to grant permission to access Google Cloud resources.
4. At the command prompt, select a Google Cloud project from the list of those where you have Owner, Editor or Viewer permissions:
Pick cloud project to use: [1] [my-project-1] [2] [my-project-2] ... Please enter your numeric choice:
If you only have one project, gcloud init selects it for you.
If you have access to more than 200 projects, you will be prompted to enter a project id, create a new project, or list projects.
This account has a lot of projects! Listing them all can take a while. [1] Enter a project ID [2] Create a new project [3] List projects Please enter your numeric choice:
5. If you have the Google Compute Engine API enabled, gcloud init allows you to choose a default Compute Engine zone:
Which compute zone would you like to use as project default? [1] [asia-east1-a] [2] [asia-east1-b] ... [14] Do not use default zone Please enter your numeric choice:
gcloud init confirms that you have complete the setup steps successfully:
gcloud has now been configured! You can use [gcloud config] to change more gcloud settings. Your active configuration is: [default]