简体   繁体   English

如何创建从SSAS数据库备份的作业?

[英]how can I create job for make Back Up From SSAS Database?

I use SQL Server 2008 R2 and SSAS. 我使用SQL Server 2008 R2和SSAS。

I have some dimensional DataBase in SSAS. 我在SSAS中有一些维数据库。

I need create a job for make back up from all DataBase of SSAS in each days. 我需要创建一份工作,以便每天从SSAS的所有DataBase备份。

How i can do it? 我怎么能这样做?

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: 1 /使用Analysis Services命令创建SQL作业作为步骤,每个数据库使用与此类似的代码:

<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 这很简单,如果您只有一些SSAS数据库,您不会定期删除或添加更多数据库,维护起来相对轻松

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): 2 /创建一个SSAS链接服务器,然后在作业步骤中使用常规SQL语句来传递命令(由于您可以使用变量来修改文件名等内容,因此可以提供更多灵活性):

Create SSAS Linked Server 创建SSAS链接服务器

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: 编辑:使用此方法您还可以使用以下方法从Analysis Server轻松获取SSAS数据库列表:

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. 然后,您可以只浏览此列表,通过列表中每个数据库的链接服务器执行SSAS命令,这意味着如果添加新的SSAS数据库,则无需手动维护作业。

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): 3 /使用powershell,下面的方法在2008 R2上不起作用,但可以修改为直接使用SMO而不是它们在SQL Server 2012中提供的好提供程序(这是我们使用的方法,下面是一个示例从我的脚本):

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. 此方法的优点是,如果添加新的SSAS数据库,则无需更改作业,脚本将自动备份,无需更改。

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. 我确定还有其他方法可以实现这一点,但这些是我用来管理SSAS备份的3种方法,我一般认为SSAS的管理方面相当痛苦,因为它似乎有点缺乏,但也许这只是我。 The new powershell bits in SQL 2012 make it much easier though. SQL 2012中新的PowerShell位使它变得更容易。

Hope this helps with at least some ideas of what you can do. 希望这有助于至少有一些关于你能做什么的想法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在SSAS中创建层次结构? - How can I create a hierarchy in SSAS? SQL Server 2005-如何为数据库一次备份创建新的备份集 - SQL Server 2005 - How can I create a new backup set for a one off back up of a database 如何使此计算得出的度量在SSAS中正确汇总? - How do I make this calculated measure roll up properly in SSAS? 如何以编程方式检查SSAS数据库/多维数据集是否正在处理? - How can I programmatically check if an SSAS database/cube is processing? 如何从视图中选择触发代理作业? - How can I make selecting from a view trigger an agent job? 如何找出我的 (localdb) SQL Server 2012 数据库的位置并进行备份? - How can I find out the location of my (localdb) SQL Server 2012 database and back it up? 如何在SSAS中创建层次结构 - How to create hierarchy in SSAS 如何运行 windows 服务来安排从数据库中选择时间执行的作业? - How can I run windows service to schedule a job which will pick time from database to execute? 如何从 web 在我的服务器上创建数据库? - How can I create a database on my server from the web? 为什么我的SQL Server数据库填满这么快,我又该如何获得空间? - Why did my SQL Server database fill up so fast, and how can I get back my space?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM