0

actualmente debo importar las base de datos individualmente con esta parte del script

> Import-Module $PSScriptRoot\..\util\utilConnection.ps1; Import-Module
> $PSScriptRoot\..\util\utilDate.ps1;
> #Import-Module $PSScriptRoot\..\logging\Logging_Functions.ps1; Import-Module AzureRM.sql
> 
> $TIMESTAMP = getTimeStamp;
> 
> 
> 
> #Login-AzureRmAccount loginRMAccount;
> 
> #Set subscription Azure setSubscriptionAzureeITTS;
> 
> Write-Output "";
> 
> $myPasswordDB = ConvertTo-SecureString $SQL_ACCOUNT_PASSWORD_QA
> -AsPlainText -Force; $myCredentialDB = New-Object System.Management.Automation.PSCredential ($SQL_ACCOUNT_NAME_QA,
> $myPasswordDB); $sqlCredential = Get-Credential -Credential
> $myCredentialDB;
> 
> $resourceGroup = "resGroupDB"; $serverName = "domserverqa"; $database
> = "(2017-09-11-09:00)dbdom_temuco"; $primarykey = $STORAGE_ACCOUNT_BACKUP_KEY; $StorageUri =
> "https://strdatabasebackup.blob.core.windows.net/strdatabasebackupblob/(2017-09-11-09:00)dbdom_temuco.bacpac";
> 
> 
> $importRequest = New-AzureRmSqlDatabaseImport –ResourceGroupName
> $resourceGroup –ServerName $serverName –DatabaseName $database
> –StorageKeytype StorageAccessKey –StorageKey $primarykey -StorageUri
> $StorageUri -AdministratorLogin $sqlCredential.UserName
> –AdministratorLoginPassword $sqlCredential.Password –Edition Basic
> –ServiceObjectiveName basic -DatabaseMaxSizeBytes 2147483648 # 2GB ->
> 2 * 1024 MB -> 2 * 1024 * 1024 KB -> 2 * 1024 * 1024 * 1024 Bytes
> 
> $importStatus = Get-AzureRmSqlDatabaseImportExportStatus
> -OperationStatusLink $importRequest.OperationStatusLink;
> 
> while ($importStatus.Status -eq "InProgress") {
>     $importStatus = Get-AzureRmSqlDatabaseImportExportStatus -OperationStatusLink $importRequest.OperationStatusLink;        
>     Write-Output ".";
>     [System.Threading.Thread]::Sleep(2000);             }

"(2017-09-11-09:00)dbdom_temuco" este dato debo modificar diariamente la fecha y dbdom_"nombre" cambiarlo dependiente la base de datos que estoy importando.

"https://strdatabasebackup.blob.core.windows.net/strdatabasebackupblob/(2017-09-11-09:00)dbdom_temuco.bacpac"; y aqui tambien debo cambiar el nombre temuco por otra base de datos.

existe alguna manera de poner todas las bases de datos juntas y que se importen todas sin tener que hacer manualmente?

1 respuesta 1

0

fue solucionado al final utilice un array y un foreach

DB_NAME_MIRROR = "mirroring_<X>(<Y>)";

$primarykey = $STORAGE_ACCOUNT_BACKUP_KEY; #strdatabasebackup

$STORAGE_URI_BACKUP = "https://strdatabasebackup.blob.core.windows.net/strdatabasebackupblob/(<Y>)<X>.bacpac";

#Arrays
$DB_ARRAY = @("dbdom_buin", "dbdom_elquisco", "dbdom_imelbosque", "dbdom_macul", "dbdom_lareina", "dbdom_mpinto", "dbdom_penalolen", "dbdom_coquimbo");

#Replace timestamp
$DB_NAME_MIRROR = $DB_NAME_MIRROR.Replace('<Y>',$TIMESTAMP);
$STORAGE_URI_BACKUP = $STORAGE_URI_BACKUP.Replace('<Y>',$TIMESTAMP);

#Debugging....
#Write-Host $DB_NAME_MIRROR;
#Write-Host $STORAGE_URI_BACKUP;


#Database import
foreach ($DB in $DB_ARRAY) 
{
    $DB_NAME_IMPORT = $DB_NAME_MIRROR.Replace('<X>',$DB);
    $URL_FILE_BACKUP = $STORAGE_URI_BACKUP.Replace('<X>',$DB);

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.