Skip to content

Instantly share code, notes, and snippets.

@edingc
Created March 9, 2020 13:37
Show Gist options
  • Save edingc/1d4a021958fc551fae3d71a821e43c50 to your computer and use it in GitHub Desktop.
Save edingc/1d4a021958fc551fae3d71a821e43c50 to your computer and use it in GitHub Desktop.
$Keep = 3
$Today = (Get-Date).DayOfWeek
# Cleanup if Monday
If ( $Today -eq "Monday" ) {
Write-Host "Running TSM cleanup."
& tsm maintenance cleanup
}
# Run TSM Backup
Write-Host "Running TSM backup."
& tsm maintenance backup -f tableau -d
# Remove Older Backups
Get-ChildItem "C:\ProgramData\Tableau\Tableau Server\data\tabsvc\files\backups" | Where-Object { $PSItem.Name -like "*.tsbak" } | Select-Object -SkipLast $Keep | Remove-Item -Force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment