3 of 3 people found this helpful
It doesn't actually require the precise extension. Asking for a .tds for an extracted published datasource will download a .tdsx. Likewise with .twb--it will download a .twbx if that's what it truly is.
And yes, your precaution of backing up / archiving this content is reasonable. It's the same thing that we do to clean up stale content once we've notified users. Note, however, that if you make a mistake, or someone wants something back, you won't be able to easily retrieve and restore additional information such as users' subscriptions, customized views, the permissions that were set, comments, tags, etc. That info lives in the postgreSQL database.
Thanks! How do you recommend managing the extension my archived file that I'm saving? Should I leave it without an extension, and try renaming it to the proper extension if a user ever requires to have it back?
For some reason my script shows me detecting the filetype based on the extension we end up with. But if you need to detect the extension, you'll want to test to see if it's a zip file. That's all a twbx / tdsx is. So if you can open it as a zip (we've used 7zip for this in the past), it's the "x-version". If not, it's just the xml (I guess it'd be even easier detecting if it's XML/text than if it's a valid zip!--you might try that instead).
2 of 2 people found this helpful
FYI I did some testing of whether I got a TWB or TWBX on downloads with Tableau Server 9.3...what I found was a dependency between whether the workbook was initially a TWB/TWBX and the data source(s):
- If the workbook had been saved as a TWBX prior to publishing then it came down as a TWBX.
- If the workbook had a Tableau data extract and/or had included files then it came down as a TWBX.
- So the only way to guarantee a TWB as a download was if the workbook a) had never been saved or only been saved as a TWB and b) only had live connections with no extracts.
If I run the command:
tabcmd get /workbooks/url.twb , (1)
I'll successfully download the workbook, with the proper extension (so .twbx if there was an extract) in the tabcmd folder. I do not have to worry about what was the actual extension.
However, if I want to save my backups to a shared folder, I have to run the command:
tabcmd get /workbooks/url.twb -f "path\filename.extension" , (2)
which is where I'm having an issue, as I have to know the extension. As knowing the extension was not required to successfully run (1), I'm thinking that I should be able to save the downloaded workbook in an arbitrary folder and let tabcmd decided of the extension (just like it does in (1).)
Here's how I managed this with python:
First, I download the object and doesn't put the extension in the name:
os.system(r'tabcmd get "/'+(r'workbooks/' if object_type=='Workbook' else r'datasources/') +object_url+ (r'.twb' if object_type=='Workbook' else r'.tds') + r'" -f "'+save_to_this_path+'"')
If the command above didn't successfully download the file, I found out that adding '?noExtract=true' to the url can help (some live connections require that extra string):
os.system(r'tabcmd get "/'+(r'workbooks/' if object_type=='Workbook' else r'datasources/') +object_url+ (r'.twb' if object_type=='Workbook' else r'.tds') + r'"?noExtract=true -f "'+save_to_this_path+'"')
Then I use the function 'is_zipfile' to add the proper extension to the file:
else: #object is a data source
All test downloads I did were successful (giving me Tableau files reflecting what was found on server.)