Created
May 24, 2016 09:52
-
-
Save nakaji/0e703867d0c2d9b6873b16ddbabcbd9a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Invoke-Sqlcmd -Query "exec sp_databases" | ?{ -not (@("master","tempdb","msdb","model") -contains $_.Item(0)) } | %{ | |
$datebaseName = $_.Item(0) | |
Write-Host ("■ {0}のフルバックアップを実行します" -f $datebaseName) | |
$backupSql=@" | |
BACKUP DATABASE {0} | |
TO DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Backup\{0}.Bak' | |
WITH FORMAT, | |
MEDIANAME = 'SQLServerBackups', | |
NAME = 'Full Backup of {0}' | |
go | |
exit | |
"@ -f $datebaseName | |
sqlcmd -q $backupSql | |
Write-Host "" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
実行結果