2

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?

greyseal96
  • 143
  • 1
  • 7
  • Just as a quick addition, I ran the diskshadow start script manually and set the output to verbose and I saw a line at the end that said: "Note: END BACKUP was not commanded, writers not notified BackupComplete." So I'm assuming that `End Backup` doesn't necessarily have to be called from the same script and that, as long as I do call it at some point later on in the process from another script, that will notify the writers that the backup is complete. I'd just prefer not to assume so, if anybody knows for sure, that would be really helpful. – greyseal96 May 09 '18 at 00:25

1 Answers1

1

You are right. The "set context persitant" keeps the snapshot after diskshadow has exited.

Just see this article

alexander.polomodov
  • 1,060
  • 3
  • 10
  • 14
Torsten
  • 26
  • 1
  • Hi @Torsten. Thanks for taking a look at my question. I think that you're going to be the winner and get the answer for this question since you're the only person to answer it in the 6 months or so since it's been asked. I looked at the linked article and it looks like the author has the the `end backup` command in the same script as the rest of the commands so it's slightly different than what I'm trying to do. However, I'm guessing that my script is working because SET CONTEXT PERSISTENT will hold onto the snapshot after the end of the script. Has that been your experience as well? – greyseal96 Nov 17 '18 at 05:36
  • This does not answer the OP's question. I am having the same problem, and I am still unsure. – Binarus Sep 02 '20 at 15:15
  • @Binarus If it makes you feel any better, I've had the scripts that I mentioned in my question running for a while and they seem to work OK. I never found out 100% for sure that this would be problem-free but if there are any problems I haven't found them yet. – greyseal96 Sep 04 '20 at 19:12
  • The associated problems show only in complex environments, e.g. with database servers. It is exactly this sort of software where the `BEGIN BACKUP` and `END BACKUP` actually effects something at all. If you don't have such software, or if you don't put it under heavy load when testing snapshots, you nearly sure won't notice problems even if you do the wrong thing. Please note that `BEGIN BACKUP` and `END BACKUP` are not just randomly named commands for `diskshadow`, but reflect functions of the Windows VSS API which are definitely needed for clean VSS snapshots. – Binarus Sep 07 '20 at 05:52