Created
August 30, 2012 08:12
-
-
Save chgeuer/3524038 to your computer and use it in GitHub Desktop.
Simple backup skript for uploading to Azure
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
# Given as free as possible: MS-PL | |
$accountname = "azureaccountname"; | |
$accountkey = [System.IO.File]::ReadAllText(".\accountkey.txt"); | |
$backupcontainername = "backup"; | |
$dllpath = [System.IO.Path]::Combine([System.Environment]::CurrentDirectory, "Microsoft.WindowsAzure.StorageClient.dll") | |
$loadresult = [Reflection.Assembly]::LoadFile($dllpath); | |
$creds = New-Object -TypeName Microsoft.WindowsAzure.StorageCredentialsAccountAndKey -ArgumentList ( $accountname, $accountkey ); | |
$useHttps = $true; | |
$account = New-Object -TypeName Microsoft.WindowsAzure.CloudStorageAccount -ArgumentList ( $creds, $useHttps ); | |
$client = [Microsoft.WindowsAzure.StorageClient.CloudStorageAccountStorageClientExtensions]::CreateCloudBlobClient($account); | |
$backupcontainer = $client.GetContainerReference($backupcontainername); | |
$backupcontainercreationresult = $backupcontainer.CreateIfNotExist(); | |
$filename = "foo.zip"; | |
$backupblob = $backupcontainer.GetBlobReference($filename); | |
Write-Host Start upload to $backupblob.Uri.AbsoluteUri; | |
$backupblob.UploadFile($filename); | |
Write-Host Done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment