Backing up Workbooks and Datasources from Tableau Server
We often see areas of Tableau Server set aside for dashboards which are ideas in development or one off publications to share some specific thoughts. The “data playground”, the “in development”, or even the “dump”. If you’re using Tableau Server, you’ll likely have one of these. They start off with good intentions, but they grow and become something of a headache to manage. A good housekeeping policy is in order. Whilst deleting items is a straight forward multi-click of those items and a delete, if you’re the conscientious type who’d like a backup before you hit delete, it’s a little more convoluted. If you want to download them beforehand, its single-click, download, de-select, re-select, download etc… it can take a while.
You can usually rely on the server admins to have backed up the Tableau Server (a great script here) but you do always need a spare server to restore any backup onto, or alternatively a little bit of luck in unzipping the backup file and tracking down what you need.
An alternative is to script the backup of certain objects so you have the files a little more readily available if they’re needed. And that’s what this blog is all about.
We’re going to utilise PowerShell for scripting capability. I’m relatively new to PowerShell, and this has been a good opportunity for me to learn the basics, so by all means feedback on what I’ve done. Depending on your environment you may need to run this script with admin privileges and/or set the execution policy for your session.
Tabcmd will be used to get the various pieces of content from the server. It assumes you’ll be connecting as an account which has appropriate access to your Tableau Server. If you’re running this script away from the server you’ll also need to ensure you’ve got a copy of tabcmd.exe installed locally. Ideally you’ll have grabbed this from your server so you ensure you have the appropriate version (link).
Tableau Server XML information files are generated by the server to allow easy access to information regarding the various objects published there. We’ll be iterating over the sites, workbooks and datasources XML files in order to drive tabcmd to do what we want.
The Script Basics
You’ll need to configure the script for your environment, which you can do by amending the variables at the top.
- Location of tabcmd file
- Where to store your output
- Tableau Server URL
- Tableau Server Username and Password for the connection (if you need extra security, consider obfuscation for the password)
- Site name (single named site or all)
- Project name (single named project or all)
- Data sources with extracted data or not
Depending upon number of items and their size, this script can take a while to execute. I’d hope its kinda obvious, but what I would say, is exercise some caution if you are running this over a large part of your server on your production server at your busiest time.
The Script Itself
To keep things simple I’m just going to include a link to the script here. I’ve added an extra .txt suffix, if you remove that you will have the ps1 PowerShell script and can edit it in the editor of your choice.