For the complete documentation index, see llms.txt. This page is also available as Markdown.

Uploading Backups to Google Cloud Bucket

This tutorial shows how to use the Google gsutil tool to access a Google Cloud Storage bucket, so that you can build your own scripts to back up your database backup files to the cloud and retrieve them as needed.

Use it together with Scheduled Database Backup: configure the tbdbbackup script first, then add a cron job that pushes the generated files to your bucket.

Install and Configure the Google Cloud SDK

The 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. The package contains the gcloud, gcloud alpha, gcloud beta, gsutil and bq commands.

  1. Update the repository with the 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
  1. 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.

  1. Run the following at a command prompt:

  1. Accept the option to log in using your Google user account:

  1. In your browser, log in to your Google user account when prompted and click Allow to grant permission to access Google Cloud resources.

  2. At the command prompt, select a Google Cloud project from the list of those where you have Owner, Editor or Viewer permissions:

If you only have one project, gcloud init selects it for you.

If you have access to more than 200 projects, you are prompted to enter a project id, create a new project, or list projects:

  1. If you have the Google Compute Engine API enabled, gcloud init allows you to choose a default Compute Engine zone:

gcloud init confirms that you have completed the setup steps successfully:

Transferring Files to the Bucket

This section shows how to upload objects to your Cloud Storage bucket. An uploaded object consists of the data you want to store along with any associated metadata.

Use the gsutil cp command:

Where:

  • OBJECT_LOCATION is the local path to your backup file - for example, /lib/tb/toolpack/pkg/database_backups for the default backup location.

  • DESTINATION_BUCKET_NAME is the name of the bucket you are uploading the object to - for example, my-bucket.

If successful, the response looks like the following example:

For code samples written in the most popular languages, see Storage Upload Object Code Samples.

Was this helpful?