Domanda

I use SQL Server 2008 R2 and SSAS.

I have some dimensional DataBase in SSAS.

I need create a job for make back up from all DataBase of SSAS in each days.

How i can do it?

È stato utile?

Soluzione

So there are a few ways:

1/ Create a SQL Job using Analysis Services Commands as steps, one for each DB using code similar to this:

<Backup xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
  <Object>
    <DatabaseID>DBName</DatabaseID>
  </Object>
  <File>\\server\share\folder\backupFile.abf</File>
  <AllowOverwrite>true</AllowOverwrite>
</Backup>

This is nice and easy and if you only have a few SSAS databases that you don't delete or add more to on a regular basis, relatively painless to maintain

2/ Create an SSAS linked server and then use a regular SQL statement in a job step to pass in your command (gives you a bit more flexibility as you can use variables to modify things like the filename etc):

Create SSAS Linked Server

DECLARE @XMLA NVARCHAR(1000) ,
              @timeStamp NVARCHAR(35);

SET @timeStamp = CONVERT(NVARCHAR, GETDATE(), 112) + '_'
    + REPLACE(CONVERT(VARCHAR(8), GETDATE(), 108), ':', '');

SET @XMLA = N'<Backup xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
  <Object>
    <DatabaseID>dbName</DatabaseID>
  </Object>
  <File>\\server\share\folder\dbName_'
    + @timeStamp + '.abf</File>
    <AllowOverwrite>true</AllowOverwrite>
    <ApplyCompression>false</ApplyCompression>
</Backup>';

EXEC (@XMLA)  AT [SSAS_LinkedServer]

EDIT: What you can also do with this method is easily get a list of SSAS databases from the Analysis Server using the following:

SELECT [catalog_name] FROM OPENQUERY([SSAS_LinkedServer],'select [catalog_name] from $system.dbschema_catalogs')

You can then just cursor through this list, executing the SSAS command through the linked server for each DB in the list therefore meaning that you don't need to maintain the job manually if you add a new SSAS database.

3/ Use powershell, this method below won't work on 2008 R2, but could be modified to use SMO directly rather than the nice provider that they provide in SQL Server 2012 (this is the method that we use and the below is a sample from my script):

import-module sqlps -disablenamechecking
$server = "SERVER\INSTANCE"
$backupPath = "\\backup-server\share\SSAS\$server\"

#Get a list of the SSAS databases on the server
$ssasDBs = dir SQLSERVER:\SQLAS\$server\databases

#Backup each SSAS database on the server
foreach ($db in $ssasDBs)
{
    $extension = Get-Date -UFormat "_%Y_%m_%d_%A_%H%M%S.abf"
    $backupFile = $backupPath+$db+$extension
    try
    {
        $db.Backup($backupFile)
    }
    catch
    {
        Write-Warning "Backup of $db Failed!!!"
    }
}

This method has the advantage that you don't have to change the job if you add a new SSAS database, it will get backed up automatically by the script with no changes.

I'm sure there are other ways to achieve this, but these are 3 ways that I have used to manage SSAS backups, I generally find the management side of SSAS rather painful as it seems to be a bit lacking, but maybe that's just me. The new powershell bits in SQL 2012 make it much easier though.

Hope this helps with at least some ideas of what you can do.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top