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
Situation Awareness
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/ Relational Database Service/ User Guide/ Working with RDS for SQL Server/ Data Restorations/ Restoring from Backup Files to a Self-Built SQL Server Database Using SSMS

Restoring from Backup Files to a Self-Built SQL Server Database Using SSMS

Updated on 2024-10-24 GMT+08:00

RDS for SQL Server backups include data backups and incremental backups (log backups) in the .bak format. The .bak files can be used to restore data to a self-managed database.

Prerequisites

You have downloaded the .bak files from the cloud to a local path of a self-managed database.

Restoring a Data Backup

  1. Use the Microsoft official tool SQL Server Management Studio (SSMS) to log in to a self-managed database.

    Figure 1 Logging in to a self-managed database

  2. Right-click Databases, and choose Restore Database from the shortcut menu.

    Figure 2 Selecting a database

  3. Select Device, add the .bak backup file, and click OK.

    Figure 3 Adding a backup file

  4. Select the database to be restored. You can select the source database from the Database drop-down list box in the Source area and change the name of the destination database in the Destination area.

    Figure 4 Selecting the source and destination databases

  5. Click OK.

    Figure 5 Successful restoration

Restoring Incremental Backups (Log Backups)

NOTE:

Before restoring log backups, ensure that the data backup has been restored and the database is in the Restoring state. Log backups must be consecutive. You must restore a database according to its backup sequence. If any backup is missing, the restoration cannot be completed.

  1. Restore the data backup by referring to 1 to 4.
  2. Click Option and set Recovery state to RESTORE WITH NORECOVERY.

    Figure 6 Setting Recovery state

  3. Check that the database status is Restoring.

    Figure 7 Checking the restoration status

  4. Right-click the database and choose Tasks > Restore > Transaction Log from the shortcut menu.

    Figure 8 Selecting a database

  5. Select From device and add the backup file to be restored.

    Figure 9 Adding a backup file

  6. If the backup file is not the last incremental backup file and you need to restore other incremental backup files, change the value of Recovery state to RESTORE WITH NORECOVERY. Otherwise, select RESTORE WITH RECOVERY for Recovery state and click OK.

    Figure 10 Restoring log backups

  7. If there are any other incremental backups that need to be restored, repeat 4 to 6 until the last log backup is restored.

FAQ

Q: Can data be restored if there is only the rdsadmin database but no target database in the downloaded .bak file?

A: Yes. The solution is as follows:

  1. The downloaded backup file contains two databases. The first database is rdsadmin, and the second database is the target database, for example, test.
  2. Query backup file header information.
    restore headeronly from disk='Local path of the .bak file'
    Figure 11 Querying backup file information
  3. Query information about the databases that were backed up.
    restore filelistonly from disk='Local path of the .bak file'

    By default, only information about the first database is read.

    Figure 12 Querying information about the databases that were backed up
  4. To read the second or third database, add with file. The value of with file is that of position in the command output of restore headeronly.
    restore filelistonly from disk='Local path of the .bak file' with file=2
    Figure 13 Querying information about other databases
  5. Restore data.
    Figure 14 Restoring data
    USE [master]
    RESTORE DATABASE [@dbname]
    FROM DISK='@path'
    WITH FILE= @file
    MOVE '@logicalname1' TO '@filepath1'
    MOVE '@logicalname2' TO '@filepath2'
    NOUNLOAD, STATS=5
    GO
    • @dbname: Database name.
    • @path: Full backup file path.
    • @file: Location of the database in the .bak file, that is, the value of position in the command output of restore headeronly.
    • @logicalname1: Logical name in the backup file and the file path of the new database. Its value is that of LogicalName in the command output of restore filelistonly.
    • @filepath1: Local path for storing physical files.
    • @logicalname2: The same as @logicalname1.
    • @filepath2: The same as @filepath1.

    Run the SQL statements above based on the header information obtained in 2 to restore the data.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback