Tableau Server users and administrators know that there are routine tasks that are extremely important to do on the Tableau Server on a regular basis, namely:
- Tableau Server backup
- Tableau Server Ziplogs – Including msinfo, netstat, and latest dump
- Tableau Server topology and configuration data backup
- Cleanup of old temporary files and logs
These backups and cleanup allow you to minimize downtime in case of potential issues on the Server, as well as optimize the speed of the Tableau Server and free up hard drive space on a regular basis.
In our example we configured Google Cloud Storage as an external storage for Tableau Server backups.
The full External Storage path would look like this: gs://public_sources_ls/tableau_server_backup/
Also, it is important to clarify that the version of Tableau Server in our example is: 2021.4.6, build number: 20214.22.0420.0834
So, let us summarize the tasks briefly once again:
- Automation process will be deployed through BASH scripts
- Automate the process of Tableau Server backup, Ziplogs, topology and configuration data backup
- Automate the process of Tableau Server logs cleanup
- As a host OS we use Linux Ubuntu Server 18.04. The script has been tested on both .RPM and .DEB Linux package managers
- As a storage for all backups we will use Google Cloud Storage
- In our case Tableau Server has been deployed as 1 node, without High-Availability
- In our case Tableau Server version is 2021.4.6, build number: 20214.22.0420.0834
- To automate these tasks we will deploy 2 scripts, which are going to run automatically through CRON jobs:
– “tsm_backup.sh” – daily Tableau Server backup configuration and logs
– “maintenance_cleanup.sh” – Tableau Server maintenance cleanup every last Sunday of the month
Sequence of actions
For the communication and manipulation with Google Cloud Storage we will use ‘gsutil tool’. Here is the link with the step-by-step installation description
To verify that gsutil has been installed successfully run this command:
Make sure that your account (“tab-svc” in our case) belongs to groups “tsmadmin”, “tableau”, “google-sudousers”, “sudo”:
On our Linux Host, we will use the following path as a storage for both scripts:
Let us create the first script “tsm_backup.sh” for daily Tableau Server backup configuration and logs:
$ sudo nano /usr/local/bin/tsm_backup.sh
‘Nano’ editor is going to create an empty .sh file which we are going to edit. Let us start the script from the variables specification (“ERRFILE” for the potential errors logs collection, “BCKNAME” for the backup names structure, “LOGSNAME” for the logs names structure).
The most important part here is to specify the path to ‘tsm’ command – the main command to manage Tableau Server through console/terminal. We have to put the full path to ‘tsm’ command, and for this we need to know our Tableau Server build version. We can always check the build version through the command:
$ tsm version
In our case the path to ‘tsm’ command looks like:
Important! It is very important to specify this path in the script, otherwise ‘tsm’ commands will not work when the script runs through Cron jobs. After each Tableau Server upgrade this path has to be changed according to new build version!
So. here is the first part of the ‘tsm_backup.sh’ script with our variables:
The next thing is to specify, for how many days you want to keep the backup files on the External storage, which means that after that all the backup files older than ‘X’ days are going to be deleted (10 days in our case). Also we specify two more variables: “backup_path” – which gets Tableau Server backup path and “log_path” which gets Tableau Server logs backup path:
After we specify all variables, we can run all backup commands:
If there are any errors during this backup process, logs could be found in:
After the backup files are created, we can copy them to our Google Cloud Storage external drive through ‘gsutil’ command:
Important! Make sure, that ‘gsutil’ path is the same for your Linux Instance, to check it you can run:
After the backup files are moved to the External storage, we can remove the source backup files:
As the final step let us remove backup files older than “X” days from Google Cloud External storage:
Save and exit the script.
Let’s create the second script “maintenance_cleanup.sh” for Tableau Server maintenance cleanup every last Sunday of the month:
$ sudo nano /usr/local/bin/maintenance_cleanup.sh
This task is more simple – we just need to stop Tableau Server, then run logs cleanup and start Tableau Server again. Here is how it looks like in BASH:
Save and exit the script.
We need to change scripts owner and permissions for both scripts, so both of them could be executed:
$ sudo chown $USER /usr/local/bin/tsm_backup.sh
$ sudo chown $USER /usr/local/bin/maintenance_cleanup.sh
$ sudo chmod 774 /usr/local/bin/tsm_backup.sh
$ sudo chmod 774 /usr/local/bin/maintenance_cleanup.sh
To run these scripts automatically on a daily basis we have to setup Cron jobs. To setup Cron jobs under your account run in the Terminal:
$ crontab -e
And add these two strings in the end of the file. Save and close the file. In our case we setup ‘tsm_backup.sh’ script run daily at 2 a.m. and ‘maintenance_cleanup.sh’ at 4 a.m. every Sunday. There are also log files generated for both tasks in user’s home directory.
To verify crontab jobs run In the Terminal:
$ crontab -l
Here is the example of the output from “tsm_backup.log”:
Both BASH scripts sources could be found on my GitHub repository page.
Autor: Vladimir Sokolenko – Senior Infrastructure Engineer | Billigence