microsoft / go-sqlcmd

The new sqlcmd, CLI for SQL Server and Azure SQL (winget install sqlcmd / sqlcmd create mssql / sqlcmd open ads)
https://learn.microsoft.com/sql/tools/sqlcmd/go-sqlcmd-utility
MIT License
323 stars 56 forks source link

Linux sqlcmd cannot restore an OLDER backup file created in SQL 2022 (16.0.4095.4) to a new server instance sql 2022 (16.0.4105.2) #505

Closed HenkAJV closed 2 months ago

HenkAJV commented 5 months ago

SQL Linux : 2022 SQLCMD: 1.5.0 GO (OI also tried sqlcmd ODBC mssql-tools18 ) Scenario: Stared SQL server on Ubuntu Linux 20.04 singe-yuser mode SQL command: use [master]; RESTORE DATABASE [master] FROM DISK = N'/var/opt/mssql/data/master.bak' WITH FILE=1, MOVE N'master' to N'/var/opt/mssql/data/master.mdf', MOVE N'mastlog' to N'/var/opt/mssql/data/mastlog.ldf', NOUNLOAD, REPLACE, STATS=5; GO output

Msg 3168, Level 16, State 1, Server redacted, Line 2 The backup of the system database on the device /var/opt/mssql/data/master.bak cannot be restored because it was created by a different version of the server (16.00.4095) than this server (16.00.4105). Msg 3013, Level 16, State 1, Server redacted, Line 2 RESTORE DATABASE is terminating abnormally.

The SQL server difference between the earlier backup was one service pack, not even a different SQL server version. It did not make sense and I wanted to report it here in case this is an issue with the sqlcmd tool.

The assumption is that one can restore a backup made in earlier versions of SQL and restore it to later versions of SQL. Am I missing something?

image

shueybubbles commented 4 months ago

I sent this issue to the SQL backup owners for insight

stuartpa commented 2 months ago

The issue here is the database in question being restore is a "system" database, not a "user" database.

Explanation here:

""" You can't restore a backup of a system database (master, model, or msdb) on a server build that differs from the build on which the backup was originally created. """

https://learn.microsoft.com/en-us/sql/relational-databases/errors-events/mssqlserver-3168-database-engine-error?view=sql-server-ver16