On 09/01/2017 12:53 PM, Bill Arlofski wrote:
> On 09/01/2017 06:36 AM, Jim Richardson wrote:
>> Bill,
>>
>> Thank you so much for the response.  This is the best possible answer I 
>> could have received.  I will put your script in play.  I will most likely 
>> make changes to have this run automagically 😊 say quarterly.  Modifications 
>> would be to pull jobs ids for those jobs and feed the script.  Unless I can 
>> somehow figure out a way with the schedule Job-overrides to assign a 
>> RunScript.  Say: (I know pie in the sky)
>>
>> Schedule {
>>   Name = "My_Cycle"
>>   Run = Level=Full feb mar may jun aug sep nov dec 1st - 5th sat at 00:00
>>   Run = Level=Full RunScript = AutoRestoreAndVerify jan apr jul oct 1st - 
>> 5th sat at 00:00
>>   Run = Level=Differential sun at 18:00
>>   Run = Level=Incremental mon at 18:00
>>   Run = Level=Differential tue at 18:00
>>   Run = Level=Incremental wed at 18:00
>>   Run = Level=Differential thu at 18:00
>>   Run = Level=Incremental fri at 18:00
>> }
>>
>> Thanks again I will update the group with my experience.
> 
> Hi Jim,
> 
> The funny thing is that I almost made a comment about this sort of thing
> (scheduling) in my previous reply, but then stopped short because I figured it
> was already getting too long. :)
> 
> This is quite simple to do just by adding a little date logic near the top of
> the script:
> 
> ----8<----rundays="Sat"
> runmons="Sep Jan Apr Jul Oct"
> now=$(date)
> day=$(echo ${now} | cut -d' ' -f1)
> mon=$(echo ${now} | cut -d' ' -f2)
> daymatch=$(echo ${rundays} | grep -i ${day})
> monmatch=$(echo ${runmons} | grep -i ${mon})
> 
> # Just print some things (for testing)
> # ------------------------------------
> # echo "Now: ${now}"
> # echo "rundays: ${rundays}"
> # echo "runmons: ${runmons}"
> # echo "Day: ${day}"
> # echo "Mon: ${mon}"
> # echo "DayMatch: ${daymatch}"
> # echo "MonMatch: ${monmatch}"
> 
> if [ -n "${daymatch}" ] && [ -n "${monmatch}"  ]; then
>   echo "The day is ${day}, which is in our list of days to run on: 
> \"${rundays}\""
>   echo "The month is ${mon}, which is in our list of months to run on:
> \"${runmons}\""
>   echo "Continuing with script..."
>     else
>       echo "Not running since either the day or month does not match our
> specified list"
>       exit 1
> fi
> ----8<----
> 
> The exit 1 is not necessary really, and will be ignored by Bacula because this
> would be in a RunsWhen = after script... Bacula cannot "fail" a job based on a
> script that is run after since the job status is already written to the
> catalog before the "after" RunScript(s) are called. ;)
> 
> Hope this help!
> 
> Best regards,
> 
> Bill
> 

Arg... Stupid word wrap...    :)

Also, to clarify my comment about the exit 1 not being necessary... Well, an
"exit" is necessary to break out of the script and not run it on the wrong
days... It is just that you would probably want an "exit 0" if used in the
script I submitted last night.

Best regards,

Bill



-- 
Bill Arlofski
http://www.revpol.com/bacula
-- Not responsible for anything below this line --

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users

Reply via email to