All Products
Search
Document Center

ApsaraDB RDS:Migrate data from an ApsaraDB RDS for SQL Server instance to a local SQL Server database

Last Updated:Mar 28, 2026

Export your RDS instance data to a self-managed SQL Server database by downloading physical backup files from the RDS console and restoring them using T-SQL RESTORE DATABASE commands.

You can also use Data Transmission Service (DTS) to migrate physical backup files or snapshot backup files from the cloud to a self-managed SQL Server instance, with ApsaraDB RDS for SQL Server as the source and your self-managed SQL Server as the destination.

Prerequisites

Before you begin, make sure you have:

  • Physical backup files created for the RDS instance. For details, see Physical backup

  • Access to the self-managed SQL Server host to run T-SQL commands

How it works

The migration follows four phases:

  1. Download the full and incremental physical backup files from the RDS console.

  2. Upload and decompress the backup files on the self-managed SQL Server host.

  3. Restore the database from the full backup (with NORECOVERY to keep it in a restoring state).

  4. Optionally apply the incremental backup, then bring the database online with RECOVERY.

Download backup files

Download the full and incremental physical backup files from the RDS console. For the download steps and link format, see Download data backup files and log backup files.

If the self-managed SQL Server host can reach the RDS instance network, download the backup files directly on the host:

wget "<download-url>"

Replace <download-url> with the download URL of the backup files.

Upload and decompress backup files

  1. Upload the downloaded backup files to the self-managed SQL Server host.

  2. Decompress the full and incremental physical backup files.

    The full and incremental backup files have the same filename after decompression. Rename them before restoring to avoid confusion. Use the format <Database name>_<Backup method>_<Date>.bak. For example: - testdb_datafull_201901071320.bakdatafull indicates a full backup - testdb_datadiff_201901071330.bakdatadiff indicates an incremental backup
  3. Note the file paths. For example:

    • Full backup: /tmp/testdb_datafull_201901071320.bak

    • Incremental backup: /tmp/testdb_datadiff_201901071330.bak

Query logical file names

Log in to the self-managed SQL Server database and run the following command to list the logical file names inside the backup file:

RESTORE FILELISTONLY FROM DISK='/tmp/testdb_datafull_201901071320.bak';
GO

The output shows the logical names for the data and log files. In this example:

  • Data file logical name: testdb

  • Log file logical name: testdb_log

image.png

Restore from full backup

Run the following command to restore the database from the full backup file and specify the target paths for the data and log files:

RESTORE DATABASE testdb FROM DISK = '/tmp/testdb_datafull_201901071320.bak' WITH REPLACE, NORECOVERY, STATS = 10,
MOVE 'testdb' TO '/var/opt/mssql/data/testdb.mdf',
MOVE 'testdb_log' TO '/var/opt/mssql/data/testdb_log.ldf';
GO

After the command completes, the testdb database status shows Restoring.

Important

If you only need to restore the full backup data, skip the next section and go directly to Bring the database online.

Path reference:

PathDescription
/var/opt/mssql/data/testdb.mdfTarget path for the data file (testdb is the logical name)
/var/opt/mssql/data/testdb_log.ldfTarget path for the log file (testdb_log is the logical name)

To find the target paths on your system, check Properties > Files of the destination database.

Apply incremental backup (optional)

Run the following command to apply the incremental backup on top of the full backup restore:

RESTORE DATABASE testdb FROM DISK = '/tmp/testdb_datadiff_201901071330.bak' WITH REPLACE, NORECOVERY, STATS = 10,
MOVE 'testdb' TO '/var/opt/mssql/data/testdb.mdf',
MOVE 'testdb_log' TO '/var/opt/mssql/data/testdb_log.ldf';
GO

After the command completes, the testdb database status shows Restoring.

Bring the database online

Run the following command to finalize the restore and bring the database to an available state:

RESTORE DATABASE testdb WITH RECOVERY;
GO

The testdb database is now online and accessible.