Total Page Preview: 000000025963
Azure Powershall - Take or get azure database back in backpack file using powershell command
In this article I am going to explain how to Take or get azure database back in backpack file using powershell command.
Get or Take Azure Database back into .bacpac Powershell Scripts :
param([string]$ConnectionString ,
[string]$DatabaseName ,
[string]$OutputFile,
[string]$SqlInstallationFolder = "C:\Program Files (x86)\Microsoft SQL Server")
$ConnectionString="Server = 127.0.0.1;Initial Catalog = ITHUBCITY;Persist Security Info=False;User ID = dbuser;Password = admin@123;
MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;"
$DatabaseName = "db_ITHUBCITY"
$OutputFile = "F:\db_ITHUBCITY.bacpac"
# Load DAC assembly.
$DacAssembly = "$SqlInstallationFolder\110\DAC\bin\Microsoft.SqlServer.Dac.dll"
Write-Host "Loading Dac Assembly: $DacAssembly"
Add-Type -Path $DacAssembly
Write-Host "Dac Assembly loaded."
# Initialize Dac service.
$now = $(Get-Date).ToString("HH:mm:ss")
$Services = new-object Microsoft.SqlServer.Dac.DacServices $ConnectionString
if ($Services -eq $null)
{
exit
}
# Start the actual export.
Write-Host "Starting backup at $DatabaseName at $now"
$Watch = New-Object System.Diagnostics.StopWatch
$Watch.Start()
$Services.ExportBacpac($OutputFile, $DatabaseName)
$Watch.Stop()
Write-Host "Backup completed in" $Watch.Elapsed.ToString()
By Brijesh Kumar
Thanks
Thank You
About Author
Brijesh Kumar
Database Developer
I have more then 6 years Experience in Microsoft Technologies - SQL Server Database, ETL
Azure Cloud - Azure SQL Database, CosmosDB, Azure Data Factory, PowerBI, Web Job, Azure Function, Azure Storage, Web Apps, Powershall
and Database Migration On-Premise to Azure Cloud.
LinkedIn : https://www.linkedin.com