在Docker容器内恢复AdventureWorks2017数据库时出现以下错误。运行SQL Server 2019 CTP 2.0(mcr.microsoft.com/mssql/server:vNext-CTP2.0-ubuntu)。备份和目标数据卷均已持久化。创建新数据库没有问题。检查路径并正确。使用2017-latest Docker镜像还原时没有任何问题。其他人是否遇到了这个问题,有解决方法吗?
“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。”
创建容器。
“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