Jun 08 2023 03:49 AM
Daily backup ssas tabular database, dynamic backup for the last 7 days.
powershell or other way can do it?
this is a sample by powershell, but it not work.
can you help me? thanks a lot.
powershell script is this:
$server = "localhost"
$database = "ssasdbdemo"
$backupPath = "D:\"
# 连接到 SSAS 服务器
$conn = New-Object Microsoft.AnalysisServices.Server
$conn.connect($server)
# 获取数据库对象
$db = $conn.databases[$database]
# 创建备份文件名
$backupFileName = "awdb-" + (Get-Date).ToString("yyyyMMdd-HHmmss") + ".abf"
# 执行备份操作
$backupFile = $backupPath + $backupFileName
$backup = $db.BackupDatabase($backupFile)
Write-Host "Backup created at $backupFile"
# 删除7天前的备份文件
$dateToKeep = (Get-Date).AddDays(-7)
Get-ChildItem -Path $backupPath -Include "awdb-*.abf" | Where-Object { $_.LastWriteTime -lt $dateToKeep } | Remove-Item -Force
# 断开连接
$conn.Disconnect()
Jun 08 2023 04:28 AM
Jun 08 2023 06:48 PM
Jun 09 2023 04:07 AM