Automating Shadowprotect Desktop 4.1.5?

User avatar
Cah
3StarLounger
Posts: 293
Joined: 26 Mar 2010, 10:53

Re: Automating Shadowprotect Desktop 4.1.5?

Post by Cah »

Attached is the zip file containing the scripts and documentation I received from Storagecraft. Use of them is completely unsupported by Storagecraft. There's a very useful post dated 03-21-2010 4:59 PM in the Storagecraft forum by FTtester with a good example script. Some important points mentioned in that post:
1. You need to edit the script with Notepad and make double-sure the parameter values you set are correct
2. You need to run the scripts from command prompt, and in Vista/Windows 7 it needs to be opened "As Administrator"
3. You need to explictily tell Windows what scripting host to use. The default is wscript (used for GUI/Windows based scripts). You need to use cscript (command line type scripts). In other words, you need to use the syntax:
C:\Myscripts>cscript BackupJobExecute_FT.vbs
4. You can have the ShadowProtect GUI open if you want to doublecheck that the script is triggering the backup
I use Autohotkey to run from command line:

Code: Select all

Runwait %comspec% /c  "cscript BackupJobExecute.vbs", K:\Z Modifications\_VBS\, hide
This is the vbs script I use - BackupJobExecute.vbs - I created the AUT0 job to run and make a full backup of my C:\ drive with no schedule. I only run it using the script:

Code: Select all

Set stdOut = WScript.Stdout
Set ShadowProtect = CreateObject ("ShadowStor.ShadowProtect")
StdOut.Write "Execute Backup job" & vbCrLf

Dim BackupJob, JobName

ON ERROR RESUME NEXT

JobName="AUTO"
Set BackupJob = ShadowProtect.Jobs.GetBackupJob(JobName)

if Err<>0 then
	StdOut.Write "GetBackupJob failed" & vbCrLf
else
	StdOut.Write "Execute " & JobName & vbCrLf
	'1 = incremental
	'2 = differential
	'3 = full
	BackupJob.Execute 3
end if
This is the ahk script that I use to check for free space, delete the oldest backup if there isn't enough space and then switch my pc off. It works for me but it could probably be more robust. I don't know how to writ it as a regular batch file.

Code: Select all

; I:\Drive is  the partition where I keep my backups
; auto is the name of the shadowprotect job and resulting spf file 

; loop through the "auto" backups to find the oldest and the largest
loop, i:\auto*.spf
{
	time := A_LoopFileTimeModified

	if first =
	{
		first := time
		path:= A_LoopFileFullPath
		formattime, date, %first%, yyyy-MM-dd HH-mm-ss
	}

	if time <= %first%
	{
		first := time
		path:= A_LoopFileFullPath
		formattime, date, %first%, yyyy-MM-dd HH-mm-ss
	}
	if size < A_LoopFileSizeMB
	size := A_LoopFileSizeMB
	
}

; if there is not enough space left on the drive delete the oldest "auto" backup
DriveSpaceFree, space, I:\

if space < %size%
filedelete %path%

; now find the number of existing "auto" backups
	
jobs = 0
loop, i:\auto*.spf
jobs++

; add 1 as going to make a new backup
jobs += 1

; execute the job, the /c switch closes the cmd window when it is finished
; the hide option hides the cnd window
; K:\Z Modifications\_VBS\ is the path to the folder containing BackupjobExecute.vbs
Runwait %comspec% /c  "cscript BackupJobExecute.vbs", K:\Z Modifications\_VBS\, hide

; start a 10 second timer to check for when the job is complete
setTimer, backUp, 10,000
return

Close:

Progress, CW800000 CTFFFFFF m2 b fs18 zh0, Shutting Down, Process Complete	
Sleep, 2000  ; 2 seconds
Progress, Off

;shutdown, 1
ExitApp

return

backUp:

	new = 0
	loop, i:\auto*.spf
	new++
	
	if (new - jobs = 0)
	{
	setTimer, backUp, off
	goto Close
	}

return
Hope this helps. If anyone has any questions I'll do my best to answer them. If anyone can improve my ahk script I'd like to know.

Chris
You do not have the required permissions to view the files attached to this post.

User avatar
BobArch2
BronzeLounger
Posts: 1239
Joined: 25 Jan 2010, 22:25
Location: Pickering, Ontario, Canada

Re: Automating Shadowprotect Desktop 4.1.5?

Post by BobArch2 »

Cah wrote:Attached is the zip file containing the scripts...
Chris,

Thanks for your efforts, sharing your AHK processes and providing the scripts.

At the present moment I'll stick with my weekly and monthly scheduled processes but will definitely take a look at the scripts to get a better grasp of the facility.

Thanks again...
Regards,
Bob

User avatar
Bigaldoc
PlatinumLounger
Posts: 3757
Joined: 24 Jan 2010, 11:00
Location: Lexington, KY, USA

Re: Automating Shadowprotect Desktop 4.1.5?

Post by Bigaldoc »

Cah wrote:Attached is the zip file containing the scripts and documentation I received from Storagecraft...
Thanks very much, Chris. That's a nice writeup and I hope, if there's ever a Shadow Protect Lounger in need, that the scripts will help.