11 Replies Latest reply on Sep 9, 2015 9:33 AM by Mike Wickman

    Need help running tabadmin from windows task scheduler.

    Mike Wickman

      Greetings,

      We are trying to set up a .bat script using tabadmin to do the backup on a daily schedule.  The .bat script works fine if I manually run it but when windows task scheduler runs it, the backup does not get created.  Below is the script I'm using.  Note that the echo commands are there just for debugging and to verify the script does in fact get started.

       

       

      echo on
      echo starting script at %date% %time% >> d:\tableau_backups\script_log.txt

      rem pause
      rem comand will replace d:\tableau_backups\backup.tsbak

      cd d:\Program Files\Tableau\Tableau Server\9.0\bin
      tabadmin backup d:\tableau_backups\backup.tsbak
      rem ping 127.0.0.1 -n 600 > nul

      echo finished script at %date% %time% >> d:\tableau_backups\script_log.txt
      echo " " >> d:\tableau_backups\script_log.txt
      rem pause

      exit 0

       

      Any suggestions are welcomed on how to get the backup function automated.  We are new to Tableau so don't have any experience with the product yet.

        • 1. Re: Need help running tabadmin from windows task scheduler.
          Damien Lesage

          Is UAC activated?

           

          If yes, you have to make sure the task is executed with the highest privileges.

          • 2. Re: Need help running tabadmin from windows task scheduler.
            Mark Fraser

            Hi Mike

             

            Does the Windows task complete successfully? What is the Last run result?

             

            To find it....

            You need to open the Task Scheduler Library

            Control Panel > System and Security > Administrative Tools > Computer Management > Task Scheduler > Task Scheduler Library

             

            Then find your task - look along the line - you want the last run result column

            Here are a few

            Cheers

            Mark

            • 3. Re: Need help running tabadmin from windows task scheduler.
              Mike Wickman

              Can you explain more on UAC and what it is/what I need to look for?

              • 4. Re: Need help running tabadmin from windows task scheduler.
                Damien Lesage

                UAC stands for User Account Control (see User Account Control - Wikipedia, the free encyclopedia).

                 

                When a command needs administrator rights, a window popup to ask you for the authorization. Unfortunately, when executing a task, you don't want this kind of window (and you won't see it popup anyway).

                 

                You need to configure your task with the highest privileges for that:

                Capture.PNG

                This works for me but I use a PowerShell script to run the backup, so I am not 100% this applies to you too.

                • 5. Re: Need help running tabadmin from windows task scheduler.
                  Mike Wickman

                  Damien, I am using the user account used by the backup admin which should have the necessary authority.  The options window has the option selected that you provided.

                   

                   

                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                  Mike (Wick) Wickman

                   

                  Waddell & Reed

                  ETS

                  Desk phone - 913-236-1663

                  Cell phone   - 913-449-6423

                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                  • 6. Re: Need help running tabadmin from windows task scheduler.
                    Damien Lesage

                    Maybe you could try to save your logs (typically your echo) in a file to check where the scripts stops.

                     

                    It should be something like:

                    script.bat >> C:\folder\log.txt 2>&1
                    
                    

                     

                    If the script stops at the tabadmin command, it's really likely that the issue is related but not necessarily due to the administrator privileges.

                     

                    EDIT: OK, you have actually integrated that to your script. What do you see in the file after the execution?

                    • 7. Re: Need help running tabadmin from windows task scheduler.
                      Mike Wickman

                      Thanks Damien, the log shows this:

                       

                      'tabadmin' is not recognized as an internal or external command,

                      operable program or batch file.

                       

                      Not sure where to go next.

                       

                       

                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                      Mike (Wick) Wickman

                       

                      Waddell & Reed

                      ETS

                      Desk phone - 913-236-1663

                      Cell phone   - 913-449-6423

                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                      • 8. Re: Need help running tabadmin from windows task scheduler.
                        Winthrop Hayes

                        Mike, I think you need to set up a global path environment variable to your tableau bin directory so that the scheduler sees tabadmin when it executes - that's where the executable is

                        • 9. Re: Need help running tabadmin from windows task scheduler.
                          Toby Erkson

                          Here's the script for my daily backup, feel free to copy it (of course you will want to change the path in lines 6 and 7):

                          @ECHO OFF
                          REM QA
                          REM  by Toby Erkson, April 2015
                          REM  Adapted from http://kb.tableausoftware.com/articles/knowledgebase/server-maintenance
                          REM  No inputs required.
                          SET sPath=D:\Application\Tableau\backups
                          SET sLogPath=D:\Application\Tableau\Tableau_Server\logs
                          SET sLogFileName=backup.log
                          SET dDate=%DATE:/=%
                          
                          ECHO.
                          ECHO. >> %sLogPath%\%sLogFileName% 2>&1
                          ECHO ----- BEGIN Daily %dDate:~-4%-%dDate:~4,2%-%dDate:~6,2% %TIME% ----- >> %sLogPath%\%sLogFileName% 2>&1
                          ECHO Backing up Tableau Server...
                          ECHO Backing up Tableau Server... >> %sLogPath%\%sLogFileName% 2>&1
                          tabadmin backup %sPath%\daily_backup_PROD.tsbak >> %sLogPath%\%sLogFileName% 2>&1
                          SET /a EL=%ERRORLEVEL%
                          IF %EL% EQU 0 GOTO Success
                          
                          :Failure
                              ECHO.
                              ECHO Backup failed.
                              ECHO Error number: %EL%
                              ECHO Backup failed. >> %sLogPath%\%sLogFileName% 2>&1
                              ECHO Error number: %EL% >> %sLogPath%\%sLogFileName% 2>&1
                              GOTO End
                          
                          :Success
                              ECHO.
                              ECHO Backup succeeded.
                              ECHO Backup file saved to in directory %sPath%
                              ECHO File name is daily_backup_PROD
                              ECHO Backup succeeded. >> %sLogPath%\%sLogFileName% 2>&1
                              ECHO Backup file saved to in directory %sPath% >> %sLogPath%\%sLogFileName% 2>&1
                              ECHO File name is daily_backup_PROD.tsbak >> %sLogPath%\%sLogFileName% 2>&1
                          
                          :End
                          REM Remove the two below REMs if running manually so you can see the output.
                          REM ECHO -- Pause --
                          REM PAUSE
                          ECHO Backup operation finished.
                          ECHO ----- END Daily ----- %TIME% >> %sLogPath%\%sLogFileName% 2>&1
                          REM The /b will return our error level
                          EXIT /b %EL%
                          
                          
                          

                           

                          Attached is the export of my scheduled task.  This will set up your task with the necessary settings.  Open your Windows Task Scheduler and while on the "Task Scheduler (Local)" action item:

                                   

                          select Action >> Import Task... and import the attached file:

                                   

                          Adjust the Triggers as necessary for the time you want it executed.

                          You'll need to edit your Actions tab so it points to the location of your batch script.

                          Finally, on the General tab click the "Change User or Group..." button and use your server administrator credentials.

                          You want to check that your "Configure for:" box is set up appropriately for your particular server.  We run a Windows 2008 R2 server.

                          Click the OK button to complete the task.

                                   

                          • 10. Re: Need help running tabadmin from windows task scheduler.
                            Toby Erkson

                            Right-click on Computer and select Properties:

                            Click "Advanced system settings":

                            Click the "Environment Variables..." button from the Advanced tab:

                            Edit the Path variable:

                            Make sure you have your path to the Tableau Server "bin" directory in your path (anywhere is fine):

                            ...\SQLLIB\FUNCTION;D:\Application\Tableau\Tableau_Server\9.0\bin;%systemroot%\Sy...

                            Click OK all the way out to save.  You may need to restart the server on which the Tableau Server resides.  Sometimes I haven't had to, sometimes I have.  One of the charms of Windows I guess.

                            • 11. Re: Need help running tabadmin from windows task scheduler.
                              Mike Wickman

                              Thanks all, adding the path solved the issue.  Below is my .bat script that ran:

                               

                              echo on

                              echo starting script at %date% %time% >> d:\tableau_backups\script_log.txt

                               

                              rem pause

                              rem command will replace d:\tableau_backups\backup.tsbak

                               

                              SET PATH=%PATH%;d:\Program Files\Tableau\Tableau Server\9.0\bin

                               

                              echo %PATH% >> d:\tableau_backups\script_log.txt

                               

                              rem cd d:\Program Files\Tableau\Tableau Server\9.0\bin

                              tabadmin backup d:\tableau_backups\backup.tsbak >> d:\tableau_backups\log.txt 2>&1

                               

                              rem call d:\Program Files\Tableau\Tableau Server\9.0\bin\tabadmin.exe backup d:\tableau_backups\backup.tsbak >> d:\tableau_backups\log.txt 2>&1

                              rem ping 127.0.0.1 -n 600 > nul

                               

                              echo finished script at %date% %time% >> d:\tableau_backups\script_log.txt

                              echo " " >> d:\tableau_backups\script_log.txt

                              rem pause

                               

                              exit 0

                               

                               

                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                              Mike (Wick) Wickman

                               

                              Waddell & Reed

                              ETS

                              Desk phone - 913-236-1663

                              Cell phone   - 913-449-6423

                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~