Overview

GaussDB(DWS) provides gs_dump and gs_dumpall to export required database objects and related information. To migrate database information, you can use a tool to import the exported metadata to a target database. gs_dump exports a single database or its objects. gs_dumpall exports all databases or global objects in a cluster. For details, see Table 1.

Table 1 Application scenarios

Application Scenario

Export Granularity

Export Format

Import Method

Exporting a single database

Database-level export

  • Export full information of a database.

    You can use the exported information to create a same database containing the same data as the current one.

  • Export all object definitions of a database, including the definitions of the database, functions, schemas, tables, indexes, and stored procedures.

    You can use the exported object definitions to quickly create a same database as the current one, without data.

  • Export data of a database.
  • Plain text
  • Custom
  • Directory
  • .tar

Schema-level export

  • Export full information of a schema.
  • Export data of a schema.
  • Export all object definitions of a schema, including the definitions of tables, stored procedures, and indexes.
Table-level export
  • Export full information of a table.
  • Export data of a table.
  • Export the definition of a table.

Exporting all databases in a cluster

Database-level export

  • Export full information of a cluster.

    You can use the exported information to create a same cluster containing the same databases, global objects, and data as the current one.

  • Export all object definitions of a cluster, including the definitions of tablespaces, databases, functions, schemas, tables, indexes, and stored procedures.

    You can use the exported object definitions to quickly create a same cluster as the current one, containing the same databases and tablespaces but without data.

  • Export data of a cluster.

Plain text

For details about how to import data files, see Using the gsql Meta-Command \COPY to Import Data.

Global object export
  • Export tablespaces.
  • Export roles.
  • Export tablespaces and roles.

gs_dump and gs_dumpall use -U to specify the user that performs the export. If the specified user does not have the required permission, data cannot be exported. In this case, you can set --role in the export command to the role that has the permission. Then, gs_dump or gs_dumpall uses the specified role to export data. See Table 1 for application scenarios and Data Export By a User Without Required Permissions for operation details.

gs_dump and gs_dumpall encrypt the exported data files. These files are decrypted before being imported to prevent data disclosure for higher database security.

When gs_dump or gs_dumpall is used to export data from a cluster, other users can still access (read data from and write data to) databases in the cluster.

gs_dump and gs_dumpall can export complete, consistent data. For example, if gs_dump is used to export database A or gs_dumpall is used to export all databases from a cluster at T1, data of database A or all databases in the cluster at that time point will be exported, and modifications on the databases after that time point will not be exported.

Obtain gs_dump and gs_dumpall by decompressing the gsql CLI client package.

Precautions