Getting an error below when restoring a AdventureWorks2017 database within a docker container. Running SQL Server 2019 CTP 2.0 (mcr.microsoft.com/mssql/server:vNext-CTP2.0-ubuntu) Both backup and target data volume are persisted. No problems creating new database. Checked the paths and they are correct. Do not have any problems when restoring using 2017-latest docker image.
Anybody else have this issue with 2019-CTP2, workarounds?
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.
to create container.
$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 command.
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
7条答案
按热度按时间vsdwdz231#
Was able to workaround this problem, by creating an empty database first and then restoring with replace option.
vlju58qv2#
I have reproduced this issue on Windows 1909, Docker Desktop 2.3.0.3, and SQL Server 2019.
I verified 3 workarounds
I found the issue only occurs when you specify the docker -v or --mount flag to map a host folder to a container folder. Unfortunately that is exactly what I wanted to do in order to take advantage of various storage volumes attached to my host.
I was able to successfully restore databases to other folders including volume mapped folders, subject to permissions. Either ensure the folder is writable by mssql user, or run the process as root.
It also works to create the files manually before restoring over them. Note you need to use the REPLACE option in restore, even though the database does not yet exist.
vshtjzan3#
I struggled with this issue for hours. Problem is the directory didn't have full permission.
t2a7ltrp4#
Check whether you have provided full permissions to the folder to save the mdf and ldf of that database.
kxeu7u2r5#
I am running sql server on linux container, running on Windows 10 laptop. The command I used is as follows.
Once the command executes and the container is running, This will create three folders on the windows machine as follows.
Now copy your .bak file into one of those folders, say data folder.
Connect to the server running in the container using SSMS as follows. The ',1433' is optional because 1433 is default. So a dot(. representing localhost) should also work.
Next Create the database that you are trying to restore. In my case its SqlServerOnDocker
Now Right click Databases and select Restore database
Click Ok, and then ok again. Now select Options as shown below in the same Restore Database dialog.
Now click ok to restore your db.
nbysray56#
I am on a mac trying to use mounted host volumes for the data , and I found that this was down to the case of the file names.
qc6wkl3g7#
i faced the same issue on mac os. I'm using Docker desktop. So, i got such error, bc docker desktop has limitations for "virtual disk limit" setting. Open Docker Desktop -> settings -> Resources -> virtual disk limit and increase disk limit, after that change everything working fine.