Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
is there any way to dynamically backup daily ssas tabular database files for the past 7 days?
Daily backup, only retaining backup files from the past 7 days, files more than past 7 days will be deleted.
for example, today is 0613, only backup 0606-0612 daily backup files, tomorrow, 0614, only backup 0607-0613, and 0606 file will be deleted.
I had tried powershell command to do it. but the script cannot dynamically delete files, only backup no drop files. I don't know why.
this is the script:
$server = "localhost"
$database = "TabularProject2"
$backupPath = "D:\Backup\"
# Connect to SSAS server
$conn = New-Object Microsoft.AnalysisServices.Server
$conn.connect($server)
# Get database object
$db = $conn.databases[$database]
# Check if database object is null
if ($db -eq $null) {
Write-Host "Could not connect to database $database on server $server"
} else {
# Create backup file name
$backupFileName = "awdb-" + (Get-Date).ToString("yyyyMMdd-HHmmss") + ".abf"
# Execute backup operation
$backupFile = $backupPath + $backupFileName
$backup = $db.Backup($backupFile)
Write-Host "Backup created at $backupFile"
# Delete backup files older than 7 days
$dateToKeep = (Get-Date).AddDays(-7)
Get-ChildItem -Path $backupPath -Include "awdb-*.abf" | Where-Object { $_.LastWriteTime -lt $dateToKeep } | Remove-Item -Force
# Disconnect from server
$conn.Disconnect()
}
looking forward to your answer, thanks a lot.
You are passing a file object to Remove-Item which expects a string parameter. That line should probably be something like the following:
Get-ChildItem -Path $backupPath -Include "awdb-*.abf" | Where-Object { $_.LastWriteTime -lt $dateToKeep } | % { Remove-Item $_.FullName -Force }
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
7 | |
2 | |
2 | |
2 | |
1 |
User | Count |
---|---|
6 | |
5 | |
5 | |
3 | |
2 |