หน้านี้ยังไม่พร้อมใช้งานในภาษาท้องถิ่นของคุณ เรากำลังพยายามอย่างหนักเพื่อเพิ่มเวอร์ชันภาษาอื่น ๆ เพิ่มเติม ขอบคุณสำหรับการสนับสนุนเสมอมา

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ GaussDB/ User Guide/ Database Migration/ Using gs_restore to Import Data

Using gs_restore to Import Data

Updated on 2025-01-09 GMT+08:00

Scenarios

gs_restore is an import tool provided by GaussDB and works together with gs_dump. You can use gs_restore to import the files exported by gs_dump to a database. gs_restore can import the files in .tar, custom, or directory format.

gs_restore can:

  • Import data to a database.

    If a database is specified, data is imported to the database. If parallel import is enabled, the password for connecting to the database also needs to be specified. During data import, the generated columns are automatically updated and saved as common columns.

  • Import data to a script file.

    If no database is specified, a script containing the SQL statement to rebuild the database is created and written to a file or standard output. This script file is equivalent to the plain-text output of gs_dump.

You can specify and sort the data to import.

Precautions

gs_restore incrementally imports data by default. To prevent data exception caused by consecutive imports, use the -c and -e parameters for each import. -c indicates that the database objects that already exist in the database to be restored are cleared (deleted) before the database objects are rebuilt. -e indicates that if an error occurred when an SQL statement is sent to the database, the system exits. By default, the system continues to import data and displays a series of error information after the import is complete.

Preparing for Data Migration

  1. Prepare an ECS or a device that can access the GaussDB instance over EIP.
    • To connect to a GaussDB instance through an ECS, you must first create an ECS.

      For details on how to create and log in to an ECS, see Purchasing an ECS and Logging In to an ECS in Elastic Cloud Server Getting Started.

    • To connect to a GaussDB instance through a device that can access the GaussDB instance over EIP, you must:
      1. Bind an EIP to the GaussDB instance. For details, see Binding an EIP.
      2. Ensure that the local device can access the EIP that has been bound to the GaussDB instance.
  2. Install the gsql client on the prepared ECS or device that can access the GaussDB database, and connect it to the GaussDB database instance. For details, see Using gsql to Connect to a Database.

Procedure

  1. Upload the file exported by gs_dump to the device. For details about the file exported by gs_dump, see Using gs_dump and gs_dumpall to Export Data.
  2. Use gs_restore to import the definitions of all database objects from the exported file to the destination database.

    • Example 1: Use gs_restore to import the data and object definitions of the gs_example database from the gs_example_dump.tar file (in .tar format) by specifying the database IP address and an existing database (for example, gs_example_restore). In this example, only relative output information is included.
      gs_restore -U root /tmp/data/gs_example_dump.tar -p 8000 -d gs_example_restore -e -h 192.*.*.139;
      Password:
      restore operation successful
      total time: 1430  ms
    • Example 2: Use gs_restore to import the data and object definitions of the gs_example database from the gs_example_dump.tar file (in .tar format) by specifying the database IP address and an existing database (for example, gs_example_restore). In addition, the database objects that already exist in the database to be imported are cleared (deleted). In this example, only relative output information is included.
      gs_restore -U root /tmp/data/gs_example_dump.tar -p 8000 -d gs_example_restore -e -c -h 192.*.*.139;
      Password:
      restore operation successful
      total time: 1621  ms
    Table 1 Common parameters

    Parameter

    Description

    Example

    -U

    Username for database connection.

    -U jack

    -W

    User password for database connection.

    • This parameter is not required for database administrators if the trust policy is used for authentication.
    • If you connect to the database without specifying this parameter and you are not a database administrator, you will be prompted to enter the password.

    -W ********

    -d

    Name of a database to which data will be imported.

    -d backupdb

    -p

    TCP port or local Unix-domain socket file name extension on which the server is listening for connections.

    -p 8000

    -e

    If an error occurs when you send the SQL statement to the database, the system exits. Error messages are displayed after the import process is complete.

    -e

    -c

    Before re-creating database objects, clear (delete) the database objects that exist in the database to be imported.

    -c

    -s

    Only schema definitions are imported. Sequence values and data will not be imported.

    -s

Helpful Links

For more information, see:

เราใช้คุกกี้เพื่อปรับปรุงไซต์และประสบการณ์การใช้ของคุณ การเรียกดูเว็บไซต์ของเราต่อแสดงว่าคุณยอมรับนโยบายคุกกี้ของเรา เรียนรู้เพิ่มเติม

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback