Hi, is possible run script to delete files after backup if ended ok ?
Best answer by Sunil 12 May 2021, 09:21
Thanks, @Sunil !
@ITStorageEWL , feel free to mark his reply as the Best Answer if it satisfies your needs
I did some testing, this way the backup phase is not tested. In some cases if the job is killed the status is 1 and the post process starts.
Sorry for the delay. Here is the example.
The Job Manager launches the command with the below arguments.
-bkplevel 1 -attempt 1 -status 1 -job 4
We are trying to access the 6th argument in the list for getting the job status.
I’ve created a sample script with this content.
IF %6==1 ( echo "Backup Phase succeeded" >> C:\postBackup.log)ELSE IF %6==2 ( echo "Backup Phase failed" >> C:\postBackup.log)
echo %1 >> C:\postBackup.logecho %2 >> C:\postBackup.logecho %3 >> C:\postBackup.logecho %4 >> C:\postBackup.logecho %5 >> C:\postBackup.logecho %6 >> C:\postBackup.log
And the script output from C:\postBackup.log is this.
"Backup Phase succeeded" -bkplevel 1 -attempt 1 -status 1
This is how the script is configured in the subclient properties:
You can use %6 argument to access the jobStatus code inside your script.
So you can check IF %6==1 and delete the files you wanted to delete.
hi guys, @Sunil @Mike Struening any news?
Let me try it in the lab setup and get back.
@Sunil , do you have any examples of a script using the status argument?
@Mike Struening we have not solved it, we are still testing. Need to figure out how to intercept status 1 of the backup phase.It would be interesting to find practical examples of both linux and windows.Thanks
@ITStorageEWL , let me know if this is resolved or if you need more help.
@ITStorageEWL following up on this. Were you able to get the script running as desired?
@ITStorageEWL the status argument will only prevent the script running if the prior phase has failed. Is the prior phase failing? If the backup phase works (assuming this is a post backup script), then the script will run.
I’ll tag in @Sunil for any additional context.
You can always just do it within the script as you said, though it might be tougher to monitor the phase of the backup/scan, etc.
@Mike Struening does not work, the logs always show status 1, and it always runs the post process.
the correct syntax is
C:\Users\xxxx\Documents\echo.bat "-status 1".
should the status be tested outside or inside the script?
@Mike Struening OK I'll try some more tests. Thanks
@ITStorageEWL you don’t HAVE to add in that parameter; it’s there if you want to force the script to make a more informed decision to only run IF a prior event succeeded/failed, etc.
You should be able to test it out with a VERY small subclient with some random text files thrown in. Set the subclient to that folder only, set the script syntax to delete that folder’s content and run a full and see what happens.
@Mike Struening I did some more tests, it seems that in my case you don't have to insert any arguments.…
waiting for confirmation....
While we wait for @Sunil I am going to send this page to our documentation team to see if we can get examples added for clarity!
@Sunil sorry, do you have some examples? I am testing the solution, but probably I am wrong to pass the parameters...Thanks
C:\Users\xxxx\Documents\echo.bat "-status 1"
Ok, great! This is a very common arrangement.
Here’s another thread where I shared some of my old troubleshooting techniques that will likely help you in testing:
Let me know if this answers your questions!
“Is your intent to stage files in a folder, have them get backed up, then delete them after (to clear the staging area)? “ YES
@Sunil beat me to it! You can set the pre/post process to run pretty much any script you can come up with. You (or commonly, a vendor) have to create the script itself, and we can execute it (as the listed user in the config).
Assuming you’d set this to run AFTER the backup phase, then you likely won’t encounter any issues with premature deletion; however, if the backup is killed BEFORE the script portion runs, then you’ll likely the files sitting in place where you expected them to have been deleted.
Is your intent to stage files in a folder, have them get backed up, then delete them after (to clear the staging area)?
You can pass the job status as an argument to the post-process script. And you need to decide your business logic based on the status value.
Please check this documentation page and check the additional argument -status.
Already have an account? Login
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.
Sorry, we're still checking this file's contents to make sure it's safe to download. Please try again in a few minutes.
Sorry, our virus scanner detected that this file isn't safe to download.
We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.