dsccommunity / SqlServerDsc

This module contains DSC resources for deployment and configuration of Microsoft SQL Server.
MIT License
360 stars 225 forks source link

Restore-SqlDscDatabase: New command proposal #2026

Open johlju opened 6 months ago

johlju commented 6 months ago

Command proposal

Command that restores a database on a SQL Server Database Engine instance.

Proposed parameters

Parameter Mandatory Data type Description Default value Allowed values
ParameterName Yes String Detailed description None None

Special considerations or limitations

Suggest using WorldWideImporters for the tests as suggested in issue #1836.

Not sure this command would work best if it used SMO as suggested for a resource in issue #954 or build and invoke a T-SQL script like below.

USE [master];
GO
RESTORE DATABASE [WideWorldImporters]
FROM DISK = 'C:\Temp\WideWorldImporters.bak'
WITH
    MOVE 'WWI_Primary' TO 'C:\Data\WideWorldImporters.mdf',
    MOVE 'WWI_UserData' TO 'C:\Data\WideWorldImporters_UserData.ndf',
    MOVE 'WWI_Log' TO 'C:\Data\WideWorldImporters.ldf',
    MOVE 'WWI_InMemory_Data_1' TO 'C:\Data\WideWorldImporters_InMemory_Data_1',
    FILE = 1,
    NOUNLOAD,
    STATS = 5;
GO
johlju commented 6 months ago

Documentation:

https://learn.microsoft.com/en-us/sql/t-sql/statements/restore-statements-transact-sql?view=sql-server-2016 https://learn.microsoft.com/en-us/sql/t-sql/statements/restore-statements-arguments-transact-sql?view=sql-server-2016

suganthanraj commented 3 weeks ago

I need this command in sqlserverdsc to restore the database after the Availability group creation

suganthanraj commented 3 weeks ago

How we need to incorporate this in ansible playbook?