You'll want to save the commands (using a text editor) in a batch script (.bat) or powershell script (.ps1). And then run this script from Windows scheduler. I save the script in a scripts directory, but if you save it in the Tableau bin directory you wouldn't have to use the cd command below.
Powershell enabled me to more easily upload the backups to Amazon S3, which might be interesting to you or someone else. You can see my script below and attached. Since I'm storing the backups on another machine, I keep only the last file on the server, but you could also add a command in Powershell to delete backups older than X days.
Another tip is that if you have email alerts setup in Tableau Server, you'll get an email notification when the server is back online.
# Tableau Backup
# Creates two backup files, one date-stamped, one with a standard name to facilitate automated restore
$name = Get-Date -uformat "tabbackup_%Y%m%d-%H%M.tsbak"
$name_last = "tabbackup_last.tsbak"
$bakdir = "C:\Program Files (x86)\Tableau\Tableau Server\7.0\backups"
# Backups are uploaded to Amazon S3
$key = "XXX"
$secretkey = "XXX"
$s3folder = "XXX"
cd 'C:\Program Files (x86)\Tableau\Tableau Server\7.0\bin'
# Create backup directory if it doesn't exist
new-item $bakdir -Force -Type Directory
# Backup script
.\tabadmin.bat backup $name
# Restart Tableau
# Run tabadmin cleanup both before and after running tabadmin start to clean all log locations.
# Move backup files to backups folder
move-item $name $bakdir\$name
copy-item $bakdir\$name $bakdir\$name_last
# Upload to S3
$s3 = Get-CloudS3Connection -Key $key -Secret $secretkey
$destination = $s3 | Select-CloudFolder -path $s3folder
$src = Get-CloudFilesystemConnection | Select-CloudFolder $bakdir
$src | Copy-CloudItem $destination –filter $name
$src | Copy-CloudItem $destination –filter $name_last
# Cleanup -- delete the date-stamped file, since it's been uploaded.
TableauBackup_example.ps1.zip 868 bytes
On our server I use the Windows Task Scheduler to execute the attached DOS batch file. The backuped files are stored in the .../Tableau/backups directory and the batch files reside in the .../Tableau/Scripts directory, both of which I created.
The scheduler simply points to where ever your script is located. It is up to you to provide the file path that gets to tabadmin. To help things along, I also added the bin path to my "Path" environment variable:
(Correct, that path isn't the stock default, it's one the company I work for requires). Now I don't have to worry about being in the bin folder when executing tabadmin commands -- nice
backup.bat.zip 936 bytes
1 of 1 people found this helpful
Thanks Toby - I added the following to rotate the logs, but otherwise your script worked for me without modification:
ECHO Rotating backups older than 10 days... forfiles /P "%sPath%" /S /M *.tsbak /D -10 /C "cmd /c del @PATH" ECHO Rotating log zips older than 10 days... forfiles /P "%sPath%" /S /M *.zip /D -10 /C "cmd /c del @PATH"
Thanks for sharing your scripts. I am new to Tableau admin as well as to Windows scripting and have been working to come up with just this!! You've saved me a lot of work.
Awesomeness, glad it's helpful
I have used a similar script to backup the logs to a file share and also the data into a .tsbak file.
But when I use the script to generate the logs.zip Tableau says its missing the config\workgroup.yml
I am not sure why.
When I run the command just on the regular bin directory live on the server tabadmin ziplogs all the files are there correctly. Maybe its a file share or other permissions error?
Also do you guys know of any way the checks the integrity of the .tsbak files?
Before you need to restore. If you generate backups, test the backups work at first or once in a while, what happens it the 10th backup you restore from is actually corrupted and you cannot bring you data or server back??
I would be nice if there was something that could verify the backup files are good or not corrupted.
Like if you try to restore from something this outputs to the command line.
===== Beginning to restore the backup
===== Verifying backup manifest
Please enter the password
the <insert Tab admin account here>:
===== Initializing Tableau Server File Store Remotely
--Initializing built-in extract engine data restore.
--Restoring service data from backup file
--Database restore completed
===== Validating Database schema signature
===== Schema Signature is valid
===== Initializing Tableau Server Coordination Service
--Web data connectors were distributed to all gateways
--Web data connectors restore completed
===== Building search index
===== Search index Built
===== Backup restore completed
At least something that does the Verify backup manifest??
What is cool is Tableau Server v9.3 is probably going to have a verify command for the backups.
Thanks for sharing the script. I wanted to know if the tabadmin utility will automatically find the tableau data folder or do we need specify the data folder path in the scrip. My data folder is located in C:\ProgramData\Tableau\Tableau Server\data
Jagjit, why? It should but maybe it depends on what you want. Does this have to do with back-ups?