I've been reading a lot of documentation about Diskshadow on various sites from Microsoft to blog postings and they all recommend to do something like this:
# diskshadow script commands
set verbose on
set context persistent
begin backup
add volume D: alias DataVol
create
expose %DataVol% Z:
exec <somebackupscripthere.cmd>
end backup
delete shadows exposed Z:
exit
I'd like to incorporate Diskshadow into an existing Powershell backup script that I've got and, long story short, it would be easiest if I could break up those commands around the exec
command. Something like this:
# Powershell script
diskshadow -s diskshadowStartScript.dsh
# some backup commands here...
diskshadow -s diskshadowEndScript.dsh
Here's what each of the diskshadow scripts would contain:
diskshadow Start script:
#diskshadowStartScript.dsh
set verbose on
set context persistent
begin backup
add volume d: alias DataVol
create
expose %DataVol% Z:
diskshadow End script:
#diskshadowEndScript.dsh
end backup
delete shadows exposed Z:
exit
After reading all of the documentation, it's still a little unclear whether or not Begin backup
and End backup
must be called from within the same diskshadow script or whether they can be separated into separate scripts. I know that when I leave one script, I leave the context or session behind and I can't access the environment variable that was created for the volume alias but does something like that also apply to the Begin backup
and End backup
commands? Or are those backup commands like the Delete shadows
command which can be called in separate places?