You can use gs_dump to export data and all object definitions of a schema from GaussDB(DWS). You can export one or more specified schemas as needed. You can specify the information to be exported as follows:
The user who uploads the client must have the full control permission on the target directory on the host to which the client is uploaded.
cd <Path_for_storing_the_client> unzip dws_client_8.1.x_redhat_x64.zip
Where,
source gsql_env.sh
If the following information is displayed, the GaussDB(DWS) client is successfully configured:
All things done.
gs_dump -W Password -U jack -f /home//backup/MPPDB_schema_backup -p 8000 -h 10.10.10.100 human_resource -n hr -F d
Parameter |
Description |
Example Value |
---|---|---|
-U |
Username for connecting to the database. If this parameter is not configured, the username of the connected database is used. |
-U jack |
-W |
User password for database connection.
|
-W Password |
-f |
Folder to store exported files. If this parameter is not specified, the exported files are stored in the standard output. |
-f /home//backup/MPPDB_schema_backup |
-p |
Name extension of the TCP port on which the server is listening or the local Unix domain socket. This parameter is configured to ensure connections. |
-p 8000 |
-h |
Cluster address: If a public network address is used for connection, set this parameter to Public Network Address or Public Network Domain Name. If a private network address is used for connection, set this parameter to Private Network Address or Private Network Domain Name. |
-h 10.10.10.100 |
dbname |
Name of the database to be exported. |
human_resource |
-n |
Names of schemas to be exported. Data of the specified schemas will also be exported.
|
|
-F |
Format of exported files. The values of -F are as follows:
|
-F d |
For details about other parameters, see "gs_dump" in the Tool Guide.
gs_dump -W password -U jack -f /home//backup/MPPDB_schema_backup.sql -p 8000 -h 10.10.10.100 human_resource -n hr -Z 6 -F p
gs_dump[port=''][human_resource][2017-07-21 16:05:55]: dump database human_resource successfully
gs_dump[port=''][human_resource][2017-07-21 16:05:55]: total time: 2425 ms
gs_dump -W password -U jack -f /home//backup/MPPDB_schema_data_backup.tar -p 8000 -h 10.10.10.100 human_resource -n hr -a -F t
gs_dump[port=''][human_resource][2018-11-14 15:07:16]: dump database human_resource successfully
gs_dump[port=''][human_resource][2018-11-14 15:07:16]: total time: 1865 ms
gs_dump -W password -U jack -f /home//backup/MPPDB_schema_def_backup -p 8000 -h 10.10.10.100 human_resource -n hr -s -F d gs_dump[port=''][human_resource][2018-11-14 15:11:34]: dump database human_resource successfully gs_dump[port=''][human_resource][2018-11-14 15:11:34]: total time: 1652 ms
gs_dump -W password -U jack -f /home//backup/MPPDB_schema_backup.dmp -p 8000 -h 10.10.10.100 human_resource -N hr -F c
gs_dump[port=''][human_resource][2017-07-21 16:06:31]: dump database human_resource successfully
gs_dump[port=''][human_resource][2017-07-21 16:06:31]: total time: 2522 ms
gs_dump -W password -U jack -f /home//backup/MPPDB_schema_backup1.tar -p 8000 -h 10.10.10.100 human_resource -n hr -n public -s --with-encryption AES128 --with-key 1234567812345678 -F t
gs_dump[port=''][human_resource][2017-07-21 16:07:16]: dump database human_resource successfully
gs_dump[port=''][human_resource][2017-07-21 16:07:16]: total time: 2132 ms
gs_dump -W password -U jack -f /home//backup/MPPDB_schema_backup2.dmp -p 8000 -h 10.10.10.100 human_resource -N hr -N public -F c
gs_dump[port=''][human_resource][2017-07-21 16:07:55]: dump database human_resource successfully
gs_dump[port=''][human_resource][2017-07-21 16:07:55]: total time: 2296 ms
Example 7: Use gs_dump to run the following command to export all tables, including views, sequences, and foreign tables, in the public schema, and the staffs table in the hr schema, including data and table definition. The exported files are in a custom format.
gs_dump -W password -U jack -f /home//backup/MPPDB_backup3.dmp -p 8000 -h 10.10.10.100 human_resource -t public.* -t hr.staffs -F c
gs_dump[port=''][human_resource][2018-12-13 09:40:24]: dump database human_resource successfully
gs_dump[port=''][human_resource][2018-12-13 09:40:24]: total time: 896 ms