lowlydba.sqlserver.restore module – Performs a restore operation
Note
This module is part of the lowlydba.sqlserver collection (version 2.3.4).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install lowlydba.sqlserver
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: lowlydba.sqlserver.restore
.
New in lowlydba.sqlserver 0.9.0
Synopsis
Performs a database restore operation.
Requirements
The below requirements are needed on the host that executes this module.
dbatools PowerShell module
Parameters
Parameter |
Comments |
---|---|
The name of the SQL Server credential to be used if restoring from an Azure hosted backup using Storage Access Keys. |
|
Specifies block size to use. Choices:
|
|
Number of I/O buffers to use. Default: |
|
The database to process. |
|
Path to restore the SQL Server backups to on the target instance. If only this option is specified, then all database files (data and log) will be restored to this location |
|
This value will be prefixed to all restored files (log and data). |
|
This value will be suffixed to all restored files (log and data). |
|
Path to restore FileStream data to. This option can only be specified alongside destination_data_directory. |
|
Path to restore the database log files to. This option can only be specified alongside destination_data_directory. |
|
If specified the specified directory will be recursed into (overriding the default behaviour). Choices:
|
|
Indicates to skip restoring any differential backups. Choices:
|
|
Indicates to skip restoring any log backups. Choices:
|
|
Indicates whether CDC information should be restored as part of the database. Choices:
|
|
Indicates whether replication configuration should be restored as part of the database restore operation. Choices:
|
|
Switch to indicate the backup files are in a folder structure as created by Ola Hallengreen’s maintenance scripts. This allows for faster file parsing. Choices:
|
|
Sets the size of the unit of transfer. Values must be a multiple of 64kb. Default: |
|
Indicates if the databases should be recovered after last restore. Choices:
|
|
If specified, prevents the Choices:
|
|
Path to SQL Server backup files. Paths passed in as strings will be scanned using the desired method, default is a recursive folder scan. Accepts multiple paths separated by |
|
If switch set any occurrence of the original database’s name in a data or log file will be replace with the name specified in the database_name option. Choices:
|
|
Specify a datetime string Default is to the latest point available in the specified backups. |
|
A string which will be prefixed to the start of the restore Database’s name. |
|
By default, databases will be migrated to the destination Sql Server’s default data and log directories. You can override this by using Choices:
|
|
The SQL Server instance to modify. |
|
Password for SQL Authentication. |
|
Username for SQL Authentication. |
|
If a directory is specified the database(s) will be restored into a standby state, with the standby file placed into this directory (which must exist, and be writable by the target Sql Server instance). |
|
By default the restore will stop at the first occurence of stop_mark found in the chain, passing a datetime string |
|
Switch to indicate the restore should stop before stop_mark occurs, default is to stop when mark is created. Choices:
|
|
Marked point in the transaction log to stop the restore at. |
|
Switch that tells the restore to use the default Data and Log locations on the target server. If they don’t exist, the function will try to create them. Choices:
|
|
Indicates the restore should be verified only. Choices:
|
|
Indicates if the restore is allowed to replace an existing database. Choices:
|
|
Switch that indicated file scanning should be performed by the SQL Server instance using This will scan recursively from the passed in path. You must have sysadmin role membership on the instance for this to work. Choices:
|
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: full |
Can run in check_mode and return changed status prediction without modifying target. |
|
Platforms: all |
Target OS/families that can be operated against. |
Examples
- name: Restore a Database
lowlydba.sqlserver.restore:
sql_instance: sql-01.myco.io
database: LowlyDB
- name: Restore a Database and allow future T-Log restores
lowlydba.sqlserver.restore:
sql_instance: sql-01.myco.io
database: LowlyDB1
no_recovery: true
- name: Verify backup files, no restore
lowlydba.sqlserver.restore:
sql_instance: sql-01.myco.io
database: LowlyDB2
verify_only: true
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
Modified output from the Returned: success, but not in check_mode. |