Skip to content

Collection of useful scripts for automating things to do with Microsoft SQL Server

License

Notifications You must be signed in to change notification settings

NeilCross/sql-automation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#SQL Automation scripts

These are some basic scripts that allow automated backup/restore/mirroring functionality.

Sample invocation for clone from one server and restore to another server then enable mirroring

$sourceServer = "sourceServer"
$database = "DatabaseName"
$destinationPrimary = "DestinationPrimary"
$destinationMirror = "DestinationMirror"
$witnessServer = "MirroringWitness"
$mirroringAccount = "MirroringAccount"
$backupPath = "\\destination\backup"

.\clone-database.ps1 -SourceServer $sourceServer -SourceDatabase $database -DestinationServers $destinationPrimary -BackupPath $backupPath -ForMirroring $true
.\mirror-database.ps1 -PrincipalServer $destinationPrimary -MirrorServer $destinationMirror -WitnessServer $witnessServer -DbName $database -SQLDomainAccount $mirroringAccount -BackupPath $backupPath

Sample invocation for move-database

$server = "ServerAddress"
$database = "DatabaseName"
$databasePath = "d:\new\log\path"
$logPath = "l:\new\log\path"

.\move-database.ps1 -Server $server -DatabaseName $database -DatabasePath $databasePath -LogPath $logPath

About

Collection of useful scripts for automating things to do with Microsoft SQL Server

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published