Help us understand the problem. What is going on with this article?

Windows AzureのSQL データベースをPowerShellでバックアップ

More than 5 years have passed since last update.

PowerShellを使ったSQL データベースのバックアップ

PowerShellの起動

Windows Azure PowerShellを開きます。

準備

ストレージ名を指定して、初期設定を行います。

Get-AzureSubscription -Current | Set-AzureSubscription -CurrentStorageAccountName storage1

各種設定

初期設定を行います。
SQLのサーバー名、ストレージのキー、ストレージ名、DB名、コンテナ名、Blob名(ファイル名)を変数に設定しておきます。

$dateStr = Get-Date -Format "yyyy-MM-dd-HH-mm"
$ServerName = "serverxxx"
$StorageKey = "xxxxxxxxx...."
$StorageName = "storage1"
$DatabaseName = "sampledb"
$ContainerName = "db-bak"
$BlobName = "db-"+$dateStr+".bacpac"

資格情報の入力ダイアログが表示されるのでSQL データベースのユーザー名、パスワードを入力します。

$credential = Get-Credential

エクスポートの準備

$SqlCtx = New-AzureSqlDatabaseServerContext -ServerName $ServerName -Credential $credential
$StorageCtx = New-AzureStorageContext -StorageAccountName $StorageName -StorageAccountKey $StorageKey
$Container = Get-AzureStorageContainer -Name $ContainerName -Context $StorageCtx

エクスポート実行

$exportRequest = Start-AzureSqlDatabaseExport -SqlConnectionContext $SqlCtx -StorageContainer $Container -DatabaseName $DatabaseName -BlobName $BlobName

5~10分くらいかかるので経過確認の確認

Get-AzureSqlDatabaseImportExportStatus -Request $exportRequest

完了すると
Status : Completed
になります。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした