microsoft / SqlScriptDOM

ScriptDOM/SqlDOM is a .NET library for parsing T-SQL statements and interacting with its abstract syntax tree

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for new SQL Server 2022 snapshot backup / restore functionality

arvindshmicrosoft opened this issue · comments

SQL Server 2022 introduced a new type of backup - snapshot. ScriptDom currently does not support this type of backup. Note that this is different from the database snapshot functionality, which has been around since SQL Server 2005. In addition, there are new statements (BACKUP GROUP and BACKUP SERVER) in SQL Server 2022 which work in conjunction with these snapshot backups. There are also new options like SUSPEND_FOR_SNAPSHOT_BACKUP for ALTER DATABASE and ALTER SERVER CONFIGURATION, which are not recognized by ScriptDom. Example of statements which should be handled by ScriptDom are below. There are more examples in the docs linked to earlier.

ALTER DATABASE testdb1
SET SUSPEND_FOR_SNAPSHOT_BACKUP = ON
(MODE = COPY_ONLY);

ALTER SERVER CONFIGURATION
SET SUSPEND_FOR_SNAPSHOT_BACKUP = ON
(GROUP = (testdb1, testdb2), MODE = COPY_ONLY);

BACKUP DATABASE testdb1
TO DISK = 'd:\temp\db.bkm'
WITH METADATA_ONLY, FORMAT;

RESTORE DATABASE testdb1
FROM DISK = 'd:\temp\db.bkm'
WITH METADATA_ONLY, FILE = 3, REPLACE, --> no DBNAME clause - restore first database in backup set
MOVE 'testdb1' TO 'd:\temp\snap\testdb1.mdf',
MOVE 'testdb1_log' TO 'd:\temp\snap\testdb1_log.ldf';