Skip to content

Instantly share code, notes, and snippets.

@hunt3ri
Created August 21, 2012 12:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hunt3ri/3415007 to your computer and use it in GitHub Desktop.
Save hunt3ri/3415007 to your computer and use it in GitHub Desktop.
Powershell script for backing up SQL Azure db
###############################################################################
# Description: Backup Script for Sql Azure DB
# Author: Iain Hunter
# Date: 21/08/12
###############################################################################
$today = Get-Date
$todayStr = $today.ToString("yyyyMMdd")
$backupFile = "your-db" + $todayStr + ".bacpac"
echo "Exporting backup to: $backupFile"
# Export DB to blob storage with datestamp
C:\dev\tools\DAC-ImportExport-1.6\DacIESvcCli -S YOUR-SQL-AZURE-SERVERNAME.database.windows.net -U YOUR-SQL-AZURE-USERNAME -P YOUR-SQL-AZURE-DB-PASSWORD -D YOUR-SQL-AZURE-DB-NAME -X -BLOBACCESSKEY YOUR-BLOB-STORAGE-ACCOUNT-KEY -BLOBURL YOUR-BLOB-STORAGE-ADDRESS/CONTAINER-NAME/$backupFile -ACCESSKEYTYPE storage
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment