< Back

Invoke-DbaDbLogShipping

Mon Jan 13, 2020 12:20 pm

NAME Invoke-DbaDbLogShipping



SYNOPSIS

Invoke-DbaDbLogShipping sets up log shipping for one or more databases





SYNTAX

Invoke-DbaDbLogShipping [-SourceSqlInstance] <DbaInstanceParameter> [-DestinationSqlInstance]

<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]> [[-SourceSqlCredential] <Pscredential>]

[[-SourceCredential] <Pscredential>] [[-DestinationSqlCredential] <Pscredential>] [[-DestinationCredential]

<Pscredential>] [-Database] <System.Object[]> [-SharedPath] <String> [[-LocalPath] <String>] [[-BackupJob]

<String>] [[-BackupRetention] <Int>] [[-BackupSchedule] <String>] [-BackupScheduleDisabled <Switch>]

[[-BackupScheduleFrequencyType] <System.Object>] [[-BackupScheduleFrequencyInterval] <System.Object[]>]

[[-BackupScheduleFrequencySubdayType] <System.Object>] [[-BackupScheduleFrequencySubdayInterval] <Int>]

[[-BackupScheduleFrequencyRelativeInterval] <System.Object>] [[-BackupScheduleFrequencyRecurrenceFactor] <Int>]

[[-BackupScheduleStartDate] <String>] [[-BackupScheduleEndDate] <String>] [[-BackupScheduleStartTime] <String>]

[[-BackupScheduleEndTime] <String>] [[-BackupThreshold] <Int>] [-CompressBackup <Switch>]

[[-CopyDestinationFolder] <String>] [[-CopyJob] <String>] [[-CopyRetention] <Int>] [[-CopySchedule] <String>]

[-CopyScheduleDisabled <Switch>] [[-CopyScheduleFrequencyType] <System.Object>] [[-CopyScheduleFrequencyInterval]

<System.Object[]>] [[-CopyScheduleFrequencySubdayType] <System.Object>] [[-CopyScheduleFrequencySubdayInterval]

<Int>] [[-CopyScheduleFrequencyRelativeInterval] <System.Object>] [[-CopyScheduleFrequencyRecurrenceFactor] <Int>]

[[-CopyScheduleStartDate] <String>] [[-CopyScheduleEndDate] <String>] [[-CopyScheduleStartTime] <String>]

[[-CopyScheduleEndTime] <String>] [-DisconnectUsers <Switch>] [[-FullBackupPath] <String>] [-GenerateFullBackup

<Switch>] [[-HistoryRetention] <Int>] [-NoRecovery <Switch>] [-NoInitialization <Switch>] [[-PrimaryMonitorServer]

<String>] [[-PrimaryMonitorCredential] <Pscredential>] [[-PrimaryMonitorServerSecurityMode] <System.Object>]

[-PrimaryThresholdAlertEnabled <Switch>] [[-RestoreDataFolder] <String>] [[-RestoreLogFolder] <String>]

[[-RestoreDelay] <Int>] [[-RestoreAlertThreshold] <Int>] [[-RestoreJob] <String>] [[-RestoreRetention] <Int>]

[[-RestoreSchedule] <String>] [-RestoreScheduleDisabled <Switch>] [[-RestoreScheduleFrequencyType]

<System.Object>] [[-RestoreScheduleFrequencyInterval] <System.Object[]>] [[-RestoreScheduleFrequencySubdayType]

<System.Object>] [[-RestoreScheduleFrequencySubdayInterval] <Int>] [[-RestoreScheduleFrequencyRelativeInterval]

<System.Object>] [[-RestoreScheduleFrequencyRecurrenceFactor] <Int>] [[-RestoreScheduleStartDate] <String>]

[[-RestoreScheduleEndDate] <String>] [[-RestoreScheduleStartTime] <String>] [[-RestoreScheduleEndTime] <String>]

[[-RestoreThreshold] <Int>] [[-SecondaryDatabasePrefix] <String>] [[-SecondaryDatabaseSuffix] <String>]

[[-SecondaryMonitorServer] <String>] [[-SecondaryMonitorCredential] <Pscredential>]

[[-SecondaryMonitorServerSecurityMode] <System.Object>] [-SecondaryThresholdAlertEnabled <Switch>] [-Standby

<Switch>] [[-StandbyDirectory] <String>] [-UseExistingFullBackup <Switch>] [[-UseBackupFolder] <String>] [-Force

<Switch>] [-EnableException <Switch>] [<CommonParameters>]





DESCRIPTION

Invoke-DbaDbLogShipping helps to easily set up log shipping for one or more databases.



This function will make a lot of decisions for you assuming you want default values like a daily interval for the

schedules with a 15 minute interval on the day.



There are some settings that cannot be made by the function and they need to be prepared before the function is

executed.



The following settings need to be made before log shipping can be initiated:



- Backup destination (the folder and the privileges)



- Copy destination (the folder and the privileges)



* Privileges



Make sure your agent service on both the primary and the secondary instance is an Active Directory account.



Also have the credentials ready to set the folder permissions



** Network share



The backup destination needs to be shared and have the share privileges of FULL CONTROL to Everyone.



** NTFS permissions



The backup destination must have at least read/write permissions for the primary instance agent account.



The backup destination must have at least read permissions for the secondary instance agent account.



The copy destination must have at least read/write permission for the secondary instance agent acount.





PARAMETERS

-BackupJob [<String>]

Name of the backup that will be created in the SQL Server agent.

The parameter works as a prefix where the name of the database will be added to the backup job name.

The default is "LSBackup_[databasename]"



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-BackupRetention [<Int>]

The backup retention period in minutes. Default is 4320 / 72 hours



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-BackupSchedule [<String>]

Name of the backup schedule created for the backup job.

The parameter works as a prefix where the name of the database will be added to the backup job schedule name.

Default is "LSBackupSchedule_[databasename]"



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-BackupScheduleDisabled [<Switch>]

Parameter to set the backup schedule to disabled upon creation.

By default the schedule is enabled.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-BackupScheduleEndDate [<String>]

The date on which execution of a job can stop.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-BackupScheduleEndTime [<String>]

The time on any day to end execution of a job. Format HHMMSS / 24 hour clock.

Example: '010000' for 01:00:00 AM.

Example: '140000' for 02:00:00 PM.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-BackupScheduleFrequencyInterval [<System.Object[]>]

The number of type periods to occur between each execution of the backup job.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-BackupScheduleFrequencyRecurrenceFactor [<Int>]

The number of weeks or months between the scheduled execution of a job. FrequencyRecurrenceFactor is used only

if FrequencyType is 8, "Weekly", 16, "Monthly", 32 or "MonthlyRelative".



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-BackupScheduleFrequencyRelativeInterval [<System.Object>]

A job's occurrence of FrequencyInterval in each month, if FrequencyInterval is 32 (monthlyrelative).



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-BackupScheduleFrequencySubdayInterval [<Int>]

The number of sub-day type periods to occur between each execution of the backup job.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-BackupScheduleFrequencySubdayType [<System.Object>]

Specifies the units for the sub-day FrequencyInterval.

Allowed values are "Time", "Seconds", "Minutes", "Hours"



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-BackupScheduleFrequencyType [<System.Object>]

A value indicating when a job is to be executed.

Allowed values are "Daily", "AgentStart", "IdleComputer"



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-BackupScheduleStartDate [<String>]

The date on which execution of a job can begin.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-BackupScheduleStartTime [<String>]

The time on any day to begin execution of a job. Format HHMMSS / 24 hour clock.

Example: '010000' for 01:00:00 AM.

Example: '140000' for 02:00:00 PM.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-BackupThreshold [<Int>]

Is the length of time, in minutes, after the last backup before a threshold alert error is raised.

The default is 60.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-CompressBackup [<Switch>]

Do the backups need to be compressed. By default the backups are not compressed.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-CopyDestinationFolder [<String>]

The path to copy the transaction log backup files to. This is the root directory.

A directory with the name of the database will be created in this path.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-CopyJob [<String>]

Name of the copy job that will be created in the SQL Server agent.

The parameter works as a prefix where the name of the database will be added to the copy job name.

The default is "LSBackup_[databasename]"



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-CopyRetention [<Int>]

The copy retention period in minutes. Default is 4320 / 72 hours



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-CopySchedule [<String>]

Name of the backup schedule created for the copy job.

The parameter works as a prefix where the name of the database will be added to the copy job schedule name.

Default is "LSCopy_[DestinationServerName]_[DatabaseName]"



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-CopyScheduleDisabled [<Switch>]

Parameter to set the copy schedule to disabled upon creation.

By default the schedule is enabled.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-CopyScheduleEndDate [<String>]

The date on which execution of a job can stop.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-CopyScheduleEndTime [<String>]

The time on any day to end execution of a job. Format HHMMSS / 24 hour clock.

Example: '010000' for 01:00:00 AM.

Example: '140000' for 02:00:00 PM.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-CopyScheduleFrequencyInterval [<System.Object[]>]

The number of type periods to occur between each execution of the copy job.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-CopyScheduleFrequencyRecurrenceFactor [<Int>]

The number of weeks or months between the scheduled execution of a job. FrequencyRecurrenceFactor is used only

if FrequencyType is 8, "Weekly", 16, "Monthly", 32 or "MonthlyRelative".



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-CopyScheduleFrequencyRelativeInterval [<System.Object>]

A job's occurrence of FrequencyInterval in each month, if FrequencyInterval is 32 (monthlyrelative).



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-CopyScheduleFrequencySubdayInterval [<Int>]

The number of subday type periods to occur between each execution of the copy job.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-CopyScheduleFrequencySubdayType [<System.Object>]

Specifies the units for the subday FrequencyInterval.

Allowed values are "Time", "Seconds", "Minutes", "Hours"



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-CopyScheduleFrequencyType [<System.Object>]

A value indicating when a job is to be executed.

Allowed values are "Daily", "AgentStart", "IdleComputer"



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-CopyScheduleStartDate [<String>]

The date on which execution of a job can begin.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-CopyScheduleStartTime [<String>]

The time on any day to begin execution of a job. Format HHMMSS / 24 hour clock.

Example: '010000' for 01:00:00 AM.

Example: '140000' for 02:00:00 PM.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Database [<System.Object[]>]

Database to set up log shipping for.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-DestinationCredential [<Pscredential>]

Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).



Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory -

Integrated are all supported.



For MFA support, please use Connect-DbaInstance.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-DestinationSqlCredential [<Pscredential>]

Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).



Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory -

Integrated are all supported.



For MFA support, please use Connect-DbaInstance.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-DestinationSqlInstance [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]

Destination SQL Server instance which contains the databases to be log shipped.

You must have sysadmin access and server version must be SQL Server version 2000 or greater.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-DisconnectUsers [<Switch>]

If this parameter is set in combinations of standby the users will be disconnected during restore.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-EnableException [<Switch>]

Use this switch to disable any kind of verbose messages



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Force [<Switch>]

The force parameter will ignore some errors in the parameters and assume defaults.

It will also remove the any present schedules with the same name for the specific job.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-FullBackupPath [<String>]

Path to an existing full backup. Use this when an existing backup needs to used to initialize the database on

the secondary instance.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-GenerateFullBackup [<Switch>]

If the database is not initialized on the secondary instance it can be done by creating a new full backup and

restore it for you.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-HistoryRetention [<Int>]

Is the length of time in minutes in which the history is retained.

The default value is 14420



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-LocalPath [<String>]

If the backup path is locally for the source server you can also set this value.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-NoInitialization [<Switch>]

If this parameter is set the secondary database will not be initialized.

The database needs to be on the secondary instance in recovery mode.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-NoRecovery [<Switch>]

If this parameter is set the database will be in recovery mode. The database will not be readable.

This setting is default.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-PrimaryMonitorCredential [<Pscredential>]

Allows you to login to enter a secure credential. Only needs to be used when the

PrimaryMonitorServerSecurityMode is 0 or "sqlserver"

To use: $scred = Get-Credential, then pass $scred object to the -PrimaryMonitorCredential parameter.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-PrimaryMonitorServer [<String>]

Is the name of the monitor server for the primary server.

The default is the name of the primary sql server.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-PrimaryMonitorServerSecurityMode [<System.Object>]

The security mode used to connect to the monitor server for the primary server. Allowed values are 0,

"sqlserver", 1, "windows"

The default is 1 or Windows.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-PrimaryThresholdAlertEnabled [<Switch>]

Enables the Threshold alert for the primary database



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-RestoreAlertThreshold [<Int>]

The amount of minutes after which an alert will be raised is no restore has taken place.

The default is 45 minutes.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-RestoreDataFolder [<String>]

Folder to be used to restore the database data files. Only used when parameter GenerateFullBackup or

UseExistingFullBackup are set.

If the parameter is not set the default data folder of the secondary instance will be used including the name

of the database.

If the folder is set but doesn't exist the default data folder of the secondary instance will be used

including the name of the database.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-RestoreDelay [<Int>]

In case a delay needs to be set for the restore.

The default is 0.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-RestoreJob [<String>]

Name of the restore job that will be created in the SQL Server agent.

The parameter works as a prefix where the name of the database will be added to the restore job name.

The default is "LSRestore_[databasename]"



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-RestoreLogFolder [<String>]

Folder to be used to restore the database log files. Only used when parameter GenerateFullBackup or

UseExistingFullBackup are set.

If the parameter is not set the default transaction log folder of the secondary instance will be used.

If the folder is set but doesn't exist the default transaction log folder of the secondary instance will be

used.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-RestoreRetention [<Int>]

The backup retention period in minutes. Default is 4320 / 72 hours



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-RestoreSchedule [<String>]

Name of the backup schedule created for the restore job.

The parameter works as a prefix where the name of the database will be added to the restore job schedule name.

Default is "LSRestore_[DestinationServerName]_[DatabaseName]"



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-RestoreScheduleDisabled [<Switch>]

Parameter to set the restore schedule to disabled upon creation.

By default the schedule is enabled.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-RestoreScheduleEndDate [<String>]

The date on which execution of a job can stop.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-RestoreScheduleEndTime [<String>]

The time on any day to end execution of a job. Format HHMMSS / 24 hour clock.

Example: '010000' for 01:00:00 AM.

Example: '140000' for 02:00:00 PM.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-RestoreScheduleFrequencyInterval [<System.Object[]>]

The number of type periods to occur between each execution of the restore job.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-RestoreScheduleFrequencyRecurrenceFactor [<Int>]

The number of weeks or months between the scheduled execution of a job. FrequencyRecurrenceFactor is used only

if FrequencyType is 8, "Weekly", 16, "Monthly", 32 or "MonthlyRelative".



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-RestoreScheduleFrequencyRelativeInterval [<System.Object>]

A job's occurrence of FrequencyInterval in each month, if FrequencyInterval is 32 (monthlyrelative).



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-RestoreScheduleFrequencySubdayInterval [<Int>]

The number of subday type periods to occur between each execution of the restore job.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-RestoreScheduleFrequencySubdayType [<System.Object>]

Specifies the units for the subday FrequencyInterval.

Allowed values are "Time", "Seconds", "Minutes", "Hours"



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-RestoreScheduleFrequencyType [<System.Object>]

A value indicating when a job is to be executed.

Allowed values are "Daily", "AgentStart", "IdleComputer"



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-RestoreScheduleStartDate [<String>]

The date on which execution of a job can begin.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-RestoreScheduleStartTime [<String>]

The time on any day to begin execution of a job. Format HHMMSS / 24 hour clock.

Example: '010000' for 01:00:00 AM.

Example: '140000' for 02:00:00 PM.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-RestoreThreshold [<Int>]

The number of minutes allowed to elapse between restore operations before an alert is generated.

The default value = 0



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SecondaryDatabasePrefix [<String>]

The secondary database can be renamed to include a prefix.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SecondaryDatabaseSuffix [<String>]

The secondary database can be renamed to include a suffix.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SecondaryMonitorCredential [<Pscredential>]

Allows you to login to enter a secure credential. Only needs to be used when the

SecondaryMonitorServerSecurityMode is 0 or "sqlserver"

To use: $scred = Get-Credential, then pass $scred object to the -SecondaryMonitorCredential parameter.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SecondaryMonitorServer [<String>]

Is the name of the monitor server for the secondary server.

The default is the name of the secondary sql server.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SecondaryMonitorServerSecurityMode [<System.Object>]

The security mode used to connect to the monitor server for the secondary server. Allowed values are 0,

"sqlserver", 1, "windows"

The default is 1 or Windows.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SecondaryThresholdAlertEnabled [<Switch>]

Enables the Threshold alert for the secondary database



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SharedPath [<String>]

The backup unc path to place the backup files. This is the root directory.

A directory with the name of the database will be created in this path.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SourceCredential [<Pscredential>]

Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).



Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory -

Integrated are all supported.



For MFA support, please use Connect-DbaInstance.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SourceSqlCredential [<Pscredential>]

Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).



Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory -

Integrated are all supported.



For MFA support, please use Connect-DbaInstance.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SourceSqlInstance [<DbaInstanceParameter>]

Source SQL Server instance which contains the databases to be log shipped.

You must have sysadmin access and server version must be SQL Server version 2000 or greater.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Standby [<Switch>]

If this parameter is set the database will be set to standby mode making the database readable.

If not set the database will be in recovery mode.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-StandbyDirectory [<String>]

Directory to place the standby file(s) in



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-UseBackupFolder [<String>]

This enables the user to specify a specific backup folder containing one or more backup files to initialize

the database on the secondary instance.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-UseExistingFullBackup [<Switch>]

If the database is not initialized on the secondary instance it can be done by selecting an existing full

backup

and restore it for you.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





Tags: LogShipping

Author: Sander Stad (@sqlstad), sqlstad.nl



Website: https://dbatools.io

Copyright: (c) 2018 by dbatools, licensed under MIT

License: MIT https://opensource.org/licenses/MIT



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>$params = @{



>> SourceSqlInstance = 'sql1'

>> DestinationSqlInstance = 'sql2'

>> Database = 'db1'

>> SharedPath= '\\\\sql1\\logshipping'

>> LocalPath= 'D:\\Data\\logshipping'

>> BackupScheduleFrequencyType = 'daily'

>> BackupScheduleFrequencyInterval = 1

>> CompressBackup = $true

>> CopyScheduleFrequencyType = 'daily'

>> CopyScheduleFrequencyInterval = 1

>> GenerateFullBackup = $true

>> RestoreScheduleFrequencyType = 'daily'

>> RestoreScheduleFrequencyInterval = 1

>> SecondaryDatabaseSuffix = 'DR'

>> CopyDestinationFolder = '\\\\sql2\\logshippingdest'

>> Force = $true

>> }

>>

PS C:\\> Invoke-DbaDbLogShipping @params



Sets up log shipping for database "db1" with the backup path to a network share allowing local backups.

It creates daily schedules for the backup, copy and restore job with all the defaults to be executed every 15

minutes daily.

The secondary database will be called "db1_LS".

-------------------------- EXAMPLE 2 --------------------------



PS C:\\>$params = @{



>> SourceSqlInstance = 'sql1'

>> DestinationSqlInstance = 'sql2'

>> Database = 'db1'

>> SharedPath= '\\\\sql1\\logshipping'

>> GenerateFullBackup = $true

>> Force = $true

>> }

>>

PS C:\\> Invoke-DbaDbLogShipping @params



Sets up log shipping with all defaults except that a backup file is generated.

The script will show a message that the copy destination has not been supplied and asks if you want to use the

default which would be the backup directory of the secondary server with the folder "logshipping" i.e.

"D:\\SQLBackup\\Logshiping".



RELATED LINKS

https://dbatools.io/Invoke-DbaDbLogShipping