Exit Codes

212 views
Skip to first unread message

Leonastas

unread,
Nov 2, 2011, 12:19:29 PM11/2/11
to ShadowSpawn Support
Robocopy when completed has a vast array of exit codes that can be
interpreted for status of copy job. I have been using hobocopy (great
tool, thank you candera) in a powershell script to run backups of user
PST's for my company and it has worked quite well, but now I am
testing the move to ShadowSpawn+Robocopy script. ShadowSpawn
launches, creates snapshot, starts Robocopy, Robocopy exits, exit code
is mentioned by ShadowSpawn, ShadowSpawn exits, exit code retrieved
from ShadowSpawn is what appears to be random jumble of numbers. Is
there any way that (barring the need to exit abnormally from malformed
ShadowCopy or other internal error) that ShadowSpawn can exit and pass
the same exit code as the launched program?
Example is as follows:
PS H:\ShadowSpawn_winxp> .\ShadowSpawn.exe C:\test Q: robocopy /E /
COPYALL Q: C:\test2
ShadowSpawn (c) 2011 Craig Andera. shado...@wangdera.com

Shadowing C:\test at Q:
Launching command: robocopy /E /COPYALL Q: C:\test2

-------------------------------------------------------------------------------
ROBOCOPY :: Robust File Copy for Windows :: Version
XP010
-------------------------------------------------------------------------------

Started : Wed Nov 02 11:16:32 2011

Source : Q:\
Dest : C:\test2\

Files : *.*

Options : *.* /S /E /COPYALL /R:1000000 /W:30

------------------------------------------------------------------------------
*COPIED DATA - LEFT OUT FOR READABILITY*
------------------------------------------------------------------------------

Total Copied Skipped Mismatch FAILED
Extras
Dirs : 2 1 1 0 0
0
Files : 65 65 0 0 0
0
Bytes : 0 0 0 0 0
0
Times : 0:00:00 0:00:00 0:00:00
0:00:00

Ended : Wed Nov 02 11:16:33 2011
Launched command finished with exit code: 1.
Shadowing successfully completed.
PS H:\ShadowSpawn_winxp> $lastExitCode
32769

Any help on this would be greatly appreciated (I use the exit codes to
determine if the backups should be flagged for review on failure).
Thank you

Craig Andera

unread,
Nov 2, 2011, 1:08:04 PM11/2/11
to shadowsp...@googlegroups.com
Yeah, we had to think hard about this: it turns out to be a nontrivial
problem to solve, as we need a way to indicate if ShadowSpawn itself
fails, even if the spawned program succeeds.

If you examine the output of "shadowspawn /?", you'll find this little
nugget [1]. Hopefully that gives you what you want. If not, let us
know, and we'll see what we can do to address your needs. In short,
you can subtract 32768 from the error code to get the (nonzero) exit
code of robocopy.

[1]
If there is an error while processing (e.g. ShadowSpawn fails to
create the shadow copy), ShadowSpawn exits with status 1.

If there is an error in usage (i.e. the user specifies an unknown
option), ShadowSpawn exits with status 2.

If everything else executes as expected and <command> exits with
status zero, ShadowSpawn also exits with status 0.

If everything else executes as expected and <command> exits with a
nonzero status code n, ShadowSpawn exits with status n logically OR'ed
with 32768 (0x8000). For example, robocopy exits with status 1 when
one or more files are Scopied. So, when executing

shadowspawn C:\foo X: robocopy X:\ C:\path\to\backup /mir

the exit code of ShadowSpawn would be 32769 (0x8000 | 0x1).


On Wed, Nov 2, 2011 at 12:19 PM, Leonastas <mkmas...@gmail.com>
wrote:Exit Status:

Leonastas

unread,
Nov 2, 2011, 3:11:48 PM11/2/11
to ShadowSpawn Support
I see now, my apologies, I misunderstood the help file. I thought the
32768 was a baseline for ALL exit codes not just non-zero command exit
codes, i.e. a ShadowSpawn 0 exit and a command 0 exit creates 32768.
Sorry about that, totally my bad on the misread. By the way, if you
or anyone else is interested in my Hobocopy or ShadowSpawn/Robocopy
Powershell backup scripts, let me know and I will post them. If you
desire, I would also be willing to have them included with the
ShadowSpawn/Hobocopy distribution as example scripts (I have no
objections to the license file I see included with the source code),
if I'm not getting too ahead of myself on that.

On Nov 2, 12:08 pm, Craig Andera <cand...@wangdera.com> wrote:
> Yeah, we had to think hard about this: it turns out to be a nontrivial
> problem to solve, as we need a way to indicate if ShadowSpawn itself
> fails, even if the spawned program succeeds.
>
> If you examine the output of "shadowspawn /?", you'll find this little
> nugget [1]. Hopefully that gives you what you want. If not, let us
> know, and we'll see what we can do to address your needs. In short,
> you can subtract 32768 from the error code to get the (nonzero) exit
> code of robocopy.
>
> [1]
> If there is an error while processing (e.g. ShadowSpawn fails to
> create the shadow copy), ShadowSpawn exits with status 1.
>
> If there is an error in usage (i.e. the user specifies an unknown
> option), ShadowSpawn exits with status 2.
>
> If everything else executes as expected and <command> exits with
> status zero, ShadowSpawn also exits with status 0.
>
> If everything else executes as expected and <command> exits with a
> nonzero status code n, ShadowSpawn exits with status n logically OR'ed
> with 32768 (0x8000). For example, robocopy exits with status 1 when
> one or more files are Scopied. So, when executing
>
>   shadowspawn C:\foo X: robocopy X:\ C:\path\to\backup /mir
>
> the exit code of ShadowSpawn would be 32769 (0x8000 | 0x1).
>
> On Wed, Nov 2, 2011 at 12:19 PM, Leonastas <mkmaste...@gmail.com>
> wrote:Exit Status:
>
>
>
>
>
>
>
> > Robocopy when completed has a vast array of exit codes that can be
> > interpreted for status of copy job.  I have been using hobocopy (great
> > tool, thank you candera) in a powershell script to run backups of user
> > PST's for my company and it has worked quite well, but now I am
> > testing the move to ShadowSpawn+Robocopy script.  ShadowSpawn
> > launches, creates snapshot, starts Robocopy, Robocopy exits, exit code
> > is mentioned by ShadowSpawn, ShadowSpawn exits, exit code retrieved
> > from ShadowSpawn is what appears to be random jumble of numbers.  Is
> > there any way that (barring the need to exit abnormally from malformed
> > ShadowCopy or other internal error) that ShadowSpawn can exit and pass
> > the same exit code as the launched program?
> > Example is as follows:
> > PS H:\ShadowSpawn_winxp> .\ShadowSpawn.exe C:\test Q: robocopy /E /
> > COPYALL Q: C:\test2
> > ShadowSpawn (c) 2011 Craig Andera. shadowsp...@wangdera.com

Craig Andera

unread,
Nov 3, 2011, 8:50:22 AM11/3/11
to shadowsp...@googlegroups.com
> I see now, my apologies, I misunderstood the help file.  I thought the
> 32768 was a baseline for ALL exit codes not just non-zero command exit
> codes, i.e. a ShadowSpawn 0 exit and a command 0 exit creates 32768.
> Sorry about that, totally my bad on the misread.

Is the wording confusing? If you made the mistake, other people may as
well. Suggestions for how we can improve that would be welcome.

> By the way, if you
> or anyone else is interested in my Hobocopy or ShadowSpawn/Robocopy
> Powershell backup scripts, let me know and I will post them.  If you
> desire, I would also be willing to have them included with the
> ShadowSpawn/Hobocopy distribution as example scripts (I have no
> objections to the license file I see included with the source code),
> if I'm not getting too ahead of myself on that.

I for one would definitely be interested in seeing people's
ShadowSpawn/Robocopy scripts. I could totally see putting them on the
wiki or in an examples directory.

Leonastas

unread,
Nov 3, 2011, 3:27:04 PM11/3/11
to ShadowSpawn Support, Craig Andera
No, the wordings not confusing, I just had a brain lapse for a bit
(sometimes I read a bit faster than I ought to). As to the other
thing, I have emailed you my PST backup script, please feel free to
post it/include it as you like, I just didn't want to spam this group.

Craig Andera

unread,
Jan 21, 2012, 5:42:40 PM1/21/12
to shadowsp...@googlegroups.com
Yeah, I managed to go dark for a couple of months there. I added the
backup script to the wiki [1]. Thanks!

[1] https://github.com/candera/shadowspawn/wiki/PowerShellPlusRobocopy

Reply all
Reply to author
Forward
0 new messages