在 docker 容器中恢复 AdventureWorks2017 数据库时出现以下错误。
运行 SQL Server 2019 CTP 2.0 (mcr.microsoft.com/mssql/server:vNext-CTP2.0-ubuntu)
备份和目标数据量都被持久化。
创建新数据库没有问题。
检查了路径,它们是正确的。使用 2017 年最新的 docker 镜像恢复时没有任何问题。
其他人在 2019-CTP2 上有这个问题,解决方法吗?
Msg 3634, Level 16, State 1, Line 7 The operating system returned the error '2(The system cannot find the file specified.)' while attempting 'RestoreContainer::ValidateTargetForCreation' on '/var/opt/mssql/data/AdventureWorks2017.mdf'. Msg 3156, Level 16, State 5, Line 7 File 'AdventureWorks2017' cannot be restored to '/var/opt/mssql/data/AdventureWorks2017.mdf'. Use WITH MOVE to identify a valid location for the file. Msg 3634, Level 16, State 1, Line 7 The operating system returned the error '2(The system cannot find the file specified.)' while attempting 'RestoreContainer::ValidateTargetForCreation' on '/var/opt/mssql/log/AdventureWorks2017_log.ldf'. Msg 3156, Level 16, State 5, Line 7 File 'AdventureWorks2017_log' cannot be restored to '/var/opt/mssql/log/AdventureWorks2017_log.ldf'. Use WITH MOVE to identify a valid location for the file. Msg 3119, Level 16, State 1, Line 7 Problems were identified while planning for the RESTORE statement. Previous messages provide details. Msg 3013, Level 16, State 1, Line 7 RESTORE DATABASE is terminating abnormally.
创建容器。
$datapath = "D:\Foo";
$logpath = "D:\Foo";
$backuppath = "D:\Foo";
$pass = ":-)"
$ct = (docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=$pass" `
-e "MSSQL_PID=Developer" -p 2017:1433 `
-e "MSSQL_TCP_PORT=1433" `
-v ${datapath}:/var/opt/mssql/data `
-v ${logpath}:/var/opt/mssql/log `
-v ${backuppath}:/var/opt/mssql/backup `
-e "MSSQL_BACKUP_DIR=/var/opt/mssql/backup" `
-e "MSSQL_DATA_DIR=/var/opt/mssql/data" `
-e "MSSQL_LOG_DIR=/var/opt/mssql/log" `
-d mcr.microsoft.com/mssql/server:vNext-CTP2.0-ubuntu)
恢复命令。
RESTORE DATABASE [AdventureWorks2017] FROM DISK = N'/var/opt/mssql/backup/AdventureWorks2017.bak'
WITH FILE = 1,
MOVE N'AdventureWorks2017' TO N'/var/opt/mssql/data/AdventureWorks2017.mdf',
MOVE N'AdventureWorks2017_log' TO N'/var/opt/mssql/log/AdventureWorks2017_log.ldf',
NOUNLOAD, STATS = 1
最佳答案
能够通过首先创建一个空数据库然后使用替换选项还原来解决此问题。
关于sql-server - 在 docker 容器中恢复数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53623048/