Before importing data, you must:
Create a database cluster to import the data to.
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
ororacle-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
Open the Database cluster overview page in the GDC console to see the cluster that contains the database you are importing.
Click Import. The Import data to accounts panel opens.
In the Source section of the Import data to accounts panel, specify the location of the SQL data dump file you uploaded previously.
In the Destination field, specify an existing destination database for the import.
Click Import. A banner on the GDC console shows the status of the import.
gdcloud CLI
Before using Distributed Cloud CLI, install and initialize it. Then, authenticate with your organization.
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 ofalloydbomni
,postgresql
ororacle
.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.