8 Replies Latest reply on Nov 26, 2017 11:30 PM by jo.bi Branched from an earlier discussion.

    Help, old backup files not deleting.

    jo.bi

      Hi toby,

       

      I run a batch that is supposed to remove files older than 7 days.

      However, I notice that my backup files *.tsbak* older than 7 days remain on drive..

      Any thoughts on why backups > 7days are not deleted? And how I could do so?

      Thanks, in advance,

        • 1. Re: Help, old backup files not deleting.
          Toby Erkson

          Please show us your batch script.  There are others here that are good at trouble-shooting scripts, too.

          • 2. Re: Help, old backup files not deleting.
            jo.bi

            here is a daily batch to copy extracts on network drive:

             

            SET SOURCEDIR="D:\TableauServerBackups"
            SET DESTDIR="\\network\Tableau\Tableau_backups\Tableau_server_backups"

            cd /d D:\Tableau\Tableau Server\10.3\bin
            tabadmin backup tabserver -v -d
            tabadmin cleanup

            copy *.tsbak D:\TableauServerBackups

            cd /d D:\TableauServerBackups
            SET Keep=5
            FOR /f "skip=%Keep% eol=: delims=" %%F in ('dir /b /o-d *.tsbak') do @del "%%F"

            net use UNC path password /USER:

            echo 4 >> D:\Batch_Log_Files\DailyTSBackup_log.txt
            robocopy %SOURCEDIR% %DESTDIR%

             

             

            here is a weekly batch for cleanup:

             

            tabadmin cleanup 2>> D:\Batch_Log_Files\Cleanup_log.txt

            tabadmin stop  2>> D:\Batch_Log_Files\Cleanup_log.txt

            REM tabadmin backup tabserver -v -d 2>> D:\Batch_Log_Files\Cleanup_log.txt

            tabadmin cleanup 2>> D:\Batch_Log_Files\Cleanup_log.txt

            tabadmin start  2>> D:\Batch_Log_Files\Cleanup_log.txt

            tabadmin warmup  2>> D:\Batch_Log_Files\Cleanup_log.txt

             

             

             

             

             

            I still see backups older than 7 days..

            • 3. Re: Help, old backup files not deleting.
              Jeff Strauss

              here's how I delete backups from the DR location that are older than 7 days; and it works...

               

              REM Delete older than 1 week off of the DR backup location

              pushd "%BACKUP_DESTINATION_DRPATH%"

               

              forfiles /D -7 /C "cmd /c echo @file"

               

              forfiles /D -7 /C "cmd /c del /Q @path"

              • 4. Re: Help, old backup files not deleting.
                Toby Erkson

                I use Jeff's method as well:

                REM Base location for scripts
                SET ScriptPath=D:\Application\Tableau\Scripts
                
                REM Location for this script's log file
                SET sLogPath=%ScriptPath%\script_logs
                
                REM Name for this script's log file
                SET sLogName=del_old_backups.log
                
                REM Location of backups to delete
                SET backedup=\\fileShareExample\tableau
                
                REM Location of zips to delete
                SET zips=D:\Application\Tableau\Tableau_Server\temp
                
                REM Age of files to delete
                SET backupdays=4
                
                PUSHD %backedup% >> %sLogPath%\%sLogName% 2>&1
                FORFILES /M "daily_backup_PROD*.tsbak*" /D -%backupdays% /C "cmd /c del /Q @path" >> %sLogPath%\%sLogName% 2>&1
                POPD >> %sLogPath%\%sLogName% 2>&1
                

                 

                The output, good or bad, is sent to a log file (>> %sLogPath%\%sLogName% 2>&1).

                • 5. Re: Help, old backup files not deleting.
                  jo.bi

                  Thanks for the support folks!

                  This is in Tableau Server's folder (D:\Tableau\Tableau Server\10.3\bin) that I want to remove .tsbak files that are older than 7 days.

                   

                  Jeff Strauss here is what I did but didn't work out.. can you enlighten me on this?

                  REM Delete older than 1 week off of the DR backup location

                  pushd "%D:\Tableau\Tableau Server\10.3\bin%"

                  forfiles /D -7 /C "cmd /c echo *.tsbak*"
                  forfiles /D -7 /C "cmd /c del /Q D:\Tableau\Tableau Server\10.3\bin"

                   

                  Toby Erkson I'm confused with base location for scripts, location for backups..

                  Location of backups to delete should be this folder ... D:\Tableau\Tableau Server\10.3\bin

                  Would you be kind enough to help me out?

                  • 6. Re: Help, old backup files not deleting.
                    Toby Erkson

                    I save my backups to a different file location, that's all   Simply adjust the code for your locations.  I was showing another example of Jeff's method, I borrowed from him.

                    jo.bi wrote:

                     

                    ...

                     

                    Jeff Strauss here is what I did but didn't work out.. can you enlighten me on this?

                    REM Delete older than 1 week off of the DR backup location

                    pushd "%D:\Tableau\Tableau Server\10.3\bin%"

                    ...

                    Remove the surrounding % from that line.  The surrounding % is for variable designation and since you are directly providing the file path -- not a variable -- there's no need for them in your statement.

                    • 7. Re: Help, old backup files not deleting.
                      Jeff Strauss

                      As Toby says, definitely save your backups to a different location.

                       

                       

                      Here is what I do.  The -d appends the current date onto the file.

                       

                       

                      SET TABLEAU_BACKUP_PATH=G:\TableauBackup\

                       

                      SET TABLEAU_BACKUP_FILE=tableau_backup

                       

                      tabadmin backup %TABLEAU_BACKUP_PATH%%TABLEAU_BACKUP_FILE%.tsbak -d

                      • 8. Re: Help, old backup files not deleting.
                        jo.bi

                        Thanks Jeff Strauss & Toby Erkson for your help, keep it up!