Skip to content

Instantly share code, notes, and snippets.

@rarous
Created October 29, 2010 09:19
Show Gist options
  • Select an option

  • Save rarous/653193 to your computer and use it in GitHub Desktop.

Select an option

Save rarous/653193 to your computer and use it in GitHub Desktop.
Skript pro obnovu databaze z backupu
$bak_folder = "c:\backups\db"
$sql_server_user = "sa"
$sql_server_pwd = "P4$$w0rd"
$databases = @{ "DbName"="db.bak" }
function Restore-Backups {
foreach ($db in $databases.keys) {
osql -U $sql_server_user -P $sql_server_pwd -Q "RESTORE DATABASE $db FROM disk= '$bak_folder\$($databases[$db])' WITH REPLACE;USE [$db]; ALTER USER [$db] WITH LOGIN = [$db];"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment