Import from a dump file

Before importing data, you must:

  1. Create a database cluster to import the data to.

  2. Upload the dump file to a storage bucket. See Upload objects to storage buckets for instructions.

    The Database Service import service account must have access to the dump file. The service account is named postgresql-import-DATABASE_CLUSTER_NAME or oracle-import-DATABASE_CLUSTER_NAME, depending on the type of database you are importing.

    Replace DATABASE_CLUSTER_NAME with the name of the database cluster where you are importing data.

You can import a dump file into a database cluster using either the GDC console or the Distributed Cloud CLI:

Console

  1. Open the Database cluster overview page in the GDC console to see the cluster that contains the database you are importing.

  2. Click Import. The Import data to accounts panel opens.

  3. In the Source section of the Import data to accounts panel, specify the location of the SQL data dump file you uploaded previously.

  4. In the Destination field, specify an existing destination database for the import.

  5. Click Import. A banner on the GDC console shows the status of the import.

gdcloud CLI

  1. Before using Distributed Cloud CLI, install and initialize it. Then, authenticate with your organization.

  2. Run the following command to import a dump file into a database:

    gdcloud database import sql DATABASE_CLUSTER s3://BUCKET_NAME/sample.dmp \
        --project=PROJECT_NAME
    

    Replace the following:

    • DATABASE_CLUSTER with the name of the database cluster to import data into.
    • BUCKET_NAME/SAMPLE.dmp with the location of the dump file.
    • PROJECT_NAME with the name of the project that the database cluster is in.

API

apiVersion: DBENGINE_NAME.dbadmin.gdc.goog/v1
kind: Import
metadata:
  name: IMPORT_NAME
  namespace: USER_PROJECT
spec:
  dbclusterRef: DBCLUSTER_NAME
  dumpStorage:
    s3Options:
      bucket: BUCKET_NAME
      key: DUMP_FILE_PATH
    type: S3

Replace the following variables:

  • DBENGINE_NAME: the name of the database engine. This is one of alloydbomni, postgresql or oracle.
  • IMPORT_NAME: the name of the import operation.
  • USER_PROJECT: the name of the user project where the database cluster to import is created.
  • DBCLUSTER_NAME: the name of the database cluster.
  • BUCKET_NAME: the name of the object storage bucket that stores the import files.
  • DUMP_FILE_PATH: the name of the object storage path to the stored files.