lowlydba.sqlserver.restore (2.3.2) — module

Performs a restore operation

| "added in version" 0.9.0 of lowlydba.sqlserver"

Authors: John McCall (@lowlydba)

Install collection

Install with ansible-galaxy collection install lowlydba.sqlserver:==2.3.2


Add to requirements.yml

  collections:
    - name: lowlydba.sqlserver
      version: 2.3.2

Description

Performs a database restore operation.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Restore a Database
  lowlydba.sqlserver.restore:
    sql_instance: sql-01.myco.io
    database: LowlyDB
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Restore a Database and allow future T-Log restores
  lowlydba.sqlserver.restore:
    sql_instance: sql-01.myco.io
    database: LowlyDB1
    no_recovery: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Verify backup files, no restore
  lowlydba.sqlserver.restore:
    sql_instance: sql-01.myco.io
    database: LowlyDB2
    verify_only: true

Inputs

    
path:
    description:
    - 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 C(,).
    required: true
    type: str

database:
    description:
    - The database to process.
    required: false
    type: str

keep_cdc:
    description:
    - Indicates whether CDC information should be restored as part of the database.
    required: false
    type: bool

stop_mark:
    description:
    - Marked point in the transaction log to stop the restore at.
    required: false
    type: str

block_size:
    choices:
    - 0.5kb
    - 1kb
    - 2kb
    - 4kb
    - 8kb
    - 16kb
    - 32kb
    - 64kb
    description:
    - Specifies block size to use.
    required: false
    type: str

xp_dirtree:
    description:
    - Switch that indicated file scanning should be performed by the SQL Server instance
      using C(xp_dirtree).
    - This will scan recursively from the passed in path.
    - You must have sysadmin role membership on the instance for this to work.
    required: false
    type: bool

no_recovery:
    default: false
    description:
    - Indicates if the databases should be recovered after last restore.
    required: false
    type: bool

stop_before:
    default: false
    description:
    - Switch to indicate the restore should stop before I(stop_mark) occurs, default is
      to stop when mark is created.
    required: false
    type: bool

verify_only:
    default: false
    description:
    - Indicates the restore should be verified only.
    required: false
    type: bool

buffer_count:
    default: 0
    description:
    - Number of I/O buffers to use.
    required: false
    type: int

restore_time:
    description:
    - Specify a datetime string C(HH:MM:SS MM/DD/YYYY) to which you want the database
      restored to.
    - Default is to the latest point available in the specified backups.
    required: false
    type: str

sql_instance:
    description:
    - The SQL Server instance to modify.
    required: true
    type: str

sql_password:
    description:
    - Password for SQL Authentication.
    required: false
    type: str

sql_username:
    description:
    - Username for SQL Authentication.
    required: false
    type: str

with_replace:
    default: false
    description:
    - Indicates if the restore is allowed to replace an existing database.
    required: false
    type: bool

stop_after_date:
    description:
    - By default the restore will stop at the first occurence of I(stop_mark) found in
      the chain, passing a datetime string C(HH:MM:SS MM/DD/YYYY) will cause it to stop
      the first I(stop_mark) after that datetime.
    required: false
    type: str

azure_credential:
    description:
    - The name of the SQL Server credential to be used if restoring from an Azure hosted
      backup using Storage Access Keys.
    required: false
    type: str

keep_replication:
    default: false
    description:
    - Indicates whether replication configuration should be restored as part of the database
      restore operation.
    required: false
    type: bool

directory_recurse:
    default: false
    description:
    - If specified the specified directory will be recursed into (overriding the default
      behaviour).
    required: false
    type: bool

ignore_log_backup:
    default: false
    description:
    - Indicates to skip restoring any log backups.
    required: false
    type: bool

max_transfer_size:
    default: 0
    description:
    - Sets the size of the unit of transfer. Values must be a multiple of 64kb.
    required: false
    type: int

no_xp_dir_recurse:
    default: false
    description:
    - If specified, prevents the C(XpDirTree) process from recursing (its default behaviour).
    required: false
    type: bool

standby_directory:
    description:
    - 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).
    required: false
    type: str

ignore_diff_backup:
    default: false
    description:
    - Indicates to skip restoring any differential backups.
    required: false
    type: bool

destination_file_prefix:
    description:
    - This value will be prefixed to B(all) restored files (log and data).
    required: false
    type: str

destination_file_suffix:
    description:
    - This value will be suffixed to B(all) restored files (log and data).
    required: false
    type: str

replace_db_name_in_file:
    description:
    - 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 I(database_name) option.
    required: false
    type: bool

destination_log_directory:
    description:
    - Path to restore the database log files to.
    - This option can only be specified alongside I(destination_data_directory).
    required: false
    type: str

destination_data_directory:
    description:
    - 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
    required: false
    type: str

maintenance_solution_backup:
    default: false
    description:
    - 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.
    required: false
    type: bool

restored_database_name_prefix:
    description:
    - A string which will be prefixed to the start of the restore Database's name.
    required: false
    type: str

reuse_source_folder_structure:
    description:
    - By default, databases will be migrated to the destination Sql Server's default data
      and log directories.
    - You can override this by using C(reuse_source_folder_structure).
    required: false
    type: bool

destination_filestream_directory:
    description:
    - Path to restore FileStream data to.
    - This option can only be specified alongside I(destination_data_directory).
    required: false
    type: str

use_destination_default_directories:
    description:
    - 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.
    required: false
    type: bool

Outputs

data:
  description: Modified output from the C(Restore-DbaDatabase) function.
  returned: success, but not in check_mode.
  type: dict