6 Replies Latest reply on Oct 27, 2016 1:19 PM by Charles Ayotte-Trépanier

    How to determine the file extension of published workbooks/extracts (TABCMD GET)?

    Charles Ayotte-Trépanier

      Hi,

       

      I've set up a cleanup process which identifies unused/faulty workbooks and datasources, send communications to users and ultimately delete the object.

       

      I would like to archive these objects before deleting them. Using TABCMD GET seemed like a proper way to do so. However, it requires me to know what the file extension is. For datasources, I think it would always be .tbsx (am I right?)

       

      How do I know if a workbook is a .tbw or .tbwx? Linking workbooks to the Postgres table 'extracts' can help me identify workbooks that are definitely .tbwx. However, a workbook can have live connections and still not be a .tbw .

       

      Is my approach to making a backup correct? Is there any way to obtain the file extension?

       

      Thanks for you help!

        • 1. Re: How to determine the file extension of published workbooks/extracts (TABCMD GET)?
          Matt Coles

          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.

          3 of 3 people found this helpful
          • 2. Re: How to determine the file extension of published workbooks/extracts (TABCMD GET)?
            Charles Ayotte-Trépanier

            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?

            • 3. Re: How to determine the file extension of published workbooks/extracts (TABCMD GET)?
              Matt Coles

              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).    

              • 4. Re: How to determine the file extension of published workbooks/extracts (TABCMD GET)?
                Jonathan Drummey

                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.

                 

                Jonathan

                2 of 2 people found this helpful
                • 5. Re: How to determine the file extension of published workbooks/extracts (TABCMD GET)?
                  Charles Ayotte-Trépanier

                  Thanks Jonathan!

                   

                  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).)

                   

                  Any idea/suggestions?

                   

                  Thanks!

                  • 6. Re: How to determine the file extension of published workbooks/extracts (TABCMD GET)?
                    Charles Ayotte-Trépanier

                    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:

                     

                                            if object_type=='Workbook':

                                                if zipfile.is_zipfile(save_to_this_path):

                                                    os.rename(save_to_this_path,save_to_this_path+r'.twbx')

                                                else:

                                                    os.rename(save_to_this_path,save_to_this_path+r'.twb')

                                            else: #object is a data source

                                                    os.rename(save_to_this_path,save_to_this_path+r'.tdsx')

                                                else:

                                                    os.rename(save_to_this_path,save_to_this_path+r'.tds')

                     

                     

                    All test downloads I did were successful (giving me Tableau files reflecting what was found on server.)