Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit 166cef7

Browse files
authored
Merge pull request #936 from GeKasap/patch-1
Secondary data files
2 parents f891190 + 0c78681 commit 166cef7

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

docs/linux/sql-server-linux-migrate-restore-database.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,44 @@ To restore the database backup, you can use the **RESTORE DATABASE** Transact-SQ
159159
160160
You should get a message the database is successfully restored.
161161
162+
`RESTORE DATABASE` may return an error like the following example:
163+
164+
```bash
165+
File 'YourDB_Product' cannot be restored to 'Z:\Microsoft SQL Server\MSSQL11.GLOBAL\MSSQL\Data\YourDB\YourDB_Product.ndf'. Use WITH MOVE to identify a valid location for the file.
166+
Msg 5133, Level 16, State 1, Server servername, Line 1
167+
Directory lookup for the file "Z:\Microsoft SQL Server\MSSQL11.GLOBAL\MSSQL\Data\YourDB\YourDB_Product.ndf" failed with the operating system error 2(The system cannot find the file specified.).
168+
```
169+
170+
In this case, the database contains secondary files. If these files are not specified in the `MOVE` clause of `RESTORE DATABASE`, the restore procedure will try to create them in the same path as the original server.
171+
172+
You can list all files included in the backup:
173+
```sql
174+
RESTORE FILELISTONLY FROM DISK = '/var/opt/mssql/backup/YourDB.bak'
175+
GO
176+
```
177+
You should get a list like the one below (listing only the two first columns):
178+
```sql
179+
LogicalName PhysicalName ..............
180+
----------------------------------------------------------------------------------------------------------------------
181+
YourDB Z:\Microsoft SQL Server\MSSQL11.GLOBAL\MSSQL\Data\YourDB\YourDB.mdf ..............
182+
YourDB_Product Z:\Microsoft SQL Server\MSSQL11.GLOBAL\MSSQL\Data\YourDB\YourDB_Product.ndf ..............
183+
YourDB_Customer Z:\Microsoft SQL Server\MSSQL11.GLOBAL\MSSQL\Data\YourDB\YourDB_Customer.ndf ..............
184+
YourDB_log Z:\Microsoft SQL Server\MSSQL11.GLOBAL\MSSQL\Data\YourDB\YourDB_Log.ldf ..............
185+
```
186+
187+
You can use this list to create `MOVE` clauses for the additional files. In this example, the `RESTORE DATABASE` is:
188+
189+
```sql
190+
RESTORE DATABASE YourDB
191+
FROM DISK = '/var/opt/mssql/backup/YourDB.bak'
192+
WITH MOVE 'YourDB' TO '/var/opt/mssql/data/YourDB.mdf',
193+
MOVE 'YourDB_Product' TO '/var/opt/mssql/data/YourDB_Product.ndf',
194+
MOVE 'YourDB_Customer' TO '/var/opt/mssql/data/YourDB_Customer.ndf',
195+
MOVE 'YourDB_Log' TO '/var/opt/mssql/data/YourDB_Log.ldf'
196+
GO
197+
```
198+
199+
162200
1. Verify the restoration by listing all of the databases on the server. The restored database should be listed.
163201
164202
```sql

0 commit comments

Comments
 (0)