PowerShell script exchange
Post Reply
MadAsToast
Influencer
Posts: 15
Liked: never
Joined: Jan 13, 2011 9:56 am
Full Name: Chris Hibbert
Contact:

Copy to Tape Script

Post by MadAsToast »

Greetings All,

I've been using Veeam successfully for a while now, however I am attempting to fine tune our backup solution as data has increased it is causing my previously working copy to tape script to have an issue.

Basically the script identifies the Day of the Week, and on a Saturday it calls a different job (different tape retentions) however as jobs are now dragging onto Saturday morning I am duplicating the amount of data being sent offsite (not 100% of the time but enough to be a pain) are there any scripting wizards that have written something to detect day of the week and not rerun multiple times in a day?

Code: Select all

c:
wmic path win32_localtime get dayofweek > actinium.txt
find/i "6" actinium.txt > nul
if errorlevel 1 goto Daily
Echo "Actinium Weekly Running"
"C:\Program Files\Symantec\Backup Exec\bemcmd.exe" -o1 -jActinium_Weekly
goto end
:Daily
Echo "Actinium Daily Running"
"C:\Program Files\Symantec\Backup Exec\bemcmd.exe" -o1 -jActinium_Backup
:end
del actinium.txt
This code is my current job, I guess I could make use of flag files and if exists type thing but I'm really a novice at writing scripts so it would end up being a mother of a script that probably will end up failing ;)

Any help would be greatfully appreciated.

MadAsToast

Vitaliy S.
Product Manager
Posts: 24260
Liked: 1865 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Copy to Tape Script

Post by Vitaliy S. »

Hello Chris,

How about setting archive bits on the files which have already been backed up so you do not backup VM data twice? Would this solve your issue?

If yes, then please take a look at this script and adapt it to fit in your backup policy settings.

Thanks.

MadAsToast
Influencer
Posts: 15
Liked: never
Joined: Jan 13, 2011 9:56 am
Full Name: Chris Hibbert
Contact:

Re: Copy to Tape Script

Post by MadAsToast »

Thanks for your reply, whilst this would certainly deal with the duplicate data issue, I need the script to identify the day of the week so that I can remove certain tapes offsite that are produced on a different day (fulls over incremental).

Regards

Vitaliy S.
Product Manager
Posts: 24260
Liked: 1865 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Copy to Tape Script

Post by Vitaliy S. »

I guess you could somehow use job start parameter and compare it with the current date. For example if the backup job was not triggered on Saturday, then use "daily" BE backup job, otherwise trigger a "weekly" BE job.

As for job start date parameter, then I believe you can retrieve it via PowerShell pretty easily. Hope our PS guru Seth Bartlett would be able to assist you with this.

Sethbartlett
Expert
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Copy to Tape Script

Post by Sethbartlett »

Okay so, does this script run every day and if it's Saturday, it runs one set of scripts for backup to tape retention, and any other day it runs another script. I'm not exactly sure I'm seeing the issue here. I'm guessing Friday is bleeding into Saturday and what is happening is that your script runs at the end of the job and see's that it is saturday and runs that script, and then on Saturday, does it again?
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me ;)
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.

MadAsToast
Influencer
Posts: 15
Liked: never
Joined: Jan 13, 2011 9:56 am
Full Name: Chris Hibbert
Contact:

Re: Copy to Tape Script

Post by MadAsToast »

Thanks for the replies,

The problem is two-fold really -

1) the backups bleed over the midnight time period therefore a simple "day of the week" script isn't going to clearly identify a daily from a weekly without an AM /PM stamp check. (As you highlighted it pretty much runs everything after midnight so does two lots of weeklies in some places)

2) I need weekly tapes run on the Friday night backups (a specific day Fri/Saturday either is good) my level of scripting/powerscripting is just about enough to get the backup identifying the day of the week (see my above script which I copied from another source). I haven't got much of an idea how to get this done "elegantly" hence the reason for asking here I would have expected alot of people running different retention to tapes dependent on the day?

Thanks for any help as this one is causing us to come close to missing backup windows.

Thanks

Chris

Sethbartlett
Expert
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Copy to Tape Script

Post by Sethbartlett »

Okay, so the script you have above is what you are using as a post-job script within Veeam I'm guessing? You want 1 script that if it runs on m-f, kicks off "C:\Program Files\Symantec\Backup Exec\bemcmd.exe" -o1 -jActinium_Backup and if the job ran on Saturday, you want it to kick off "C:\Program Files\Symantec\Backup Exec\bemcmd.exe" -o1 -jActinium_Weekly.

Am I correct in this? So you basically need a script that can differentiate when the job was started, rather than what day/time it's ending?
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me ;)
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.

MadAsToast
Influencer
Posts: 15
Liked: never
Joined: Jan 13, 2011 9:56 am
Full Name: Chris Hibbert
Contact:

Re: Copy to Tape Script

Post by MadAsToast »

exactly that :)

We need to identify that start time rather than the end time.

Sethbartlett
Expert
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Copy to Tape Script

Post by Sethbartlett »

What you would want to do is something like the following in powershell as a post-job script:

Code: Select all

asnp VeeamPSSnapIn
$job = Get-VBRJob | ?{$_.name -eq "QuickJob"}
$Date = $job.FindLastSession().progress.starttime

if($Date.DayofWeek -eq "Saturday")
{
	RunSaturdayJob
}
else
{
	RunOffDayJob
}
If I need to explain the code further, please let me know. Your best bet would be to put this script into a file called "tape.ps1" or something with .ps1 and put it in your C:\ drive. From there, the post job command would be like this:

Code: Select all

powershell C:\tape.ps1
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me ;)
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.

MadAsToast
Influencer
Posts: 15
Liked: never
Joined: Jan 13, 2011 9:56 am
Full Name: Chris Hibbert
Contact:

Re: Copy to Tape Script

Post by MadAsToast »

Excellent - thanks alot for this, I was looking at powershell - however I cant seem to get it to call the executable for the jobs, is it best to put the commands for the actual job into a batch file and get the ps1 file to call the batch file, as using the full bemcmd job script causes parameter issues on the -o1 part of the Invoke-Item.

Sethbartlett
Expert
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Copy to Tape Script

Post by Sethbartlett »

There aren't really executables for the jobs, you may need to uninstall/reinstall veeam and add powershell in (all your job information will still hold). You could get the ps1 to call a batch file but really, where I placed "RunSaturdayJob" you should be able to just put in "C:\Program Files\Symantec\Backup Exec\bemcmd.exe" -o1 -jActinium_Backup
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me ;)
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest