Copy to Tape Script

PowerShell script exchange

Copy to Tape Script

Veeam Logoby MadAsToast » Tue Aug 23, 2011 2:12 pm

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
MadAsToast
Influencer
 
Posts: 15
Liked: never
Joined: Thu Jan 13, 2011 9:56 am
Full Name: Chris Hibbert

Re: Copy to Tape Script

Veeam Logoby Vitaliy S. » Tue Aug 23, 2011 4:27 pm

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.
Vitaliy S.
Veeam Software
 
Posts: 19539
Liked: 1097 times
Joined: Mon Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov

Re: Copy to Tape Script

Veeam Logoby MadAsToast » Wed Aug 24, 2011 6:52 am

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
MadAsToast
Influencer
 
Posts: 15
Liked: never
Joined: Thu Jan 13, 2011 9:56 am
Full Name: Chris Hibbert

Re: Copy to Tape Script

Veeam Logoby Vitaliy S. » Wed Aug 24, 2011 11:12 am

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.
Vitaliy S.
Veeam Software
 
Posts: 19539
Liked: 1097 times
Joined: Mon Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov

Re: Copy to Tape Script

Veeam Logoby Sethbartlett » Wed Aug 24, 2011 12:29 pm

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.
Sethbartlett
Expert
 
Posts: 282
Liked: 25 times
Joined: Wed Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett

Re: Copy to Tape Script

Veeam Logoby MadAsToast » Wed Aug 24, 2011 1:06 pm

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
MadAsToast
Influencer
 
Posts: 15
Liked: never
Joined: Thu Jan 13, 2011 9:56 am
Full Name: Chris Hibbert

Re: Copy to Tape Script

Veeam Logoby Sethbartlett » Wed Aug 24, 2011 1:39 pm

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.
Sethbartlett
Expert
 
Posts: 282
Liked: 25 times
Joined: Wed Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett

Re: Copy to Tape Script

Veeam Logoby MadAsToast » Wed Aug 24, 2011 1:59 pm

exactly that :)

We need to identify that start time rather than the end time.
MadAsToast
Influencer
 
Posts: 15
Liked: never
Joined: Thu Jan 13, 2011 9:56 am
Full Name: Chris Hibbert

Re: Copy to Tape Script

Veeam Logoby Sethbartlett » Wed Aug 24, 2011 2:23 pm

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.
Sethbartlett
Expert
 
Posts: 282
Liked: 25 times
Joined: Wed Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett

Re: Copy to Tape Script

Veeam Logoby MadAsToast » Wed Aug 24, 2011 2:37 pm

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.
MadAsToast
Influencer
 
Posts: 15
Liked: never
Joined: Thu Jan 13, 2011 9:56 am
Full Name: Chris Hibbert

Re: Copy to Tape Script

Veeam Logoby Sethbartlett » Wed Aug 24, 2011 2:45 pm

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.
Sethbartlett
Expert
 
Posts: 282
Liked: 25 times
Joined: Wed Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 4 guests