Hi, is possible run script to delete files after backup if ended ok ?
Thanks
Hi, is possible run script to delete files after backup if ended ok ?
Thanks
Hi,
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.
https://documentation.commvault.com/commvault/v11_sp20/article?p=12782.htm
Thanks,
Sunil-
Hey
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)?
Thanks!
“Is your intent to stage files in a folder, have them get backed up, then delete them after (to clear the staging area)? “ YES
Ok, great! This is a very common arrangement.
Some tips:
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!
post process
C:\Users\xxxx\Documents\echo.bat "-status 1"
While we wait for
post process
C:\Users\xxxx\Documents\echo.bat
waiting for confirmation....
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.
the correct syntax is
post process
C:\Users\xxxx\Documents\echo.bat "-status 1".
or
post process
C:\Users\xxxx\Documents\echo.bat
should the status be tested outside or inside the script?
Thanks
I’ll tag in
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.
Thanks!
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
Let me try it in the lab setup and get back.
hi guys,
Thanks
Hi
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.
D:\PostBackup>type postbackup.cmd
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.log
echo %2 >> C:\postBackup.log
echo %3 >> C:\postBackup.log
echo %4 >> C:\postBackup.log
echo %5 >> C:\postBackup.log
echo %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:
That’s all.
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.
Thanks,
Sunil-
Thanks
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.
Thanks,
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.