Exit codes

Post here if you have questions about how to use the program
Posts: 10
Joined: Mon Jun 14, 2010 9:00 pm

Exit codes

Postby floor9 » Wed Jun 23, 2010 3:53 pm

Does FSArchiver return exit codes? I'm scripting an automated restore process, and I'd like to include some more detailed error handling. Today I encountered a situation where my device assignments changed based on how the laptop was booted. I can go into more detail if desired, but the end result is that my script failed because the internal drive was now (temporarily) /dev/sdb instead of /dev/sda. As a result, fsarchiver was told to restore an image to a destination that didn't exist.

I'm hoping to trap the exit codes so that I can pull off something like:

Code: Select all

(misc tasks to prepare for re-imaging)
fsarchiver restfs -j3 -v /mnt/external/current.fsa id=0,dest=/dev/sda2
if exitcode = 0 then print "success"
if exitcode = 1 then print "archive file not found; restore unsuccessful"
if exitcode = 2 then print "archive file has errors; restore unsuccessful"
if exitcode = 3 then print "destination invalid; remove your USB thumb drive and reboot"
if exitcode = 4 then print "destination too small for archive / out of space"

For my specific application, the end user wouldn't necessarily be able to resolve those errors on their own (such as a corrupt image file). But being able to show them would greatly improve feedback when they call the helpdesk.

Site Admin
Posts: 550
Joined: Sat Feb 21, 2004 12:12 pm

Re: Exit codes

Postby admin » Thu Jun 24, 2010 11:55 am

In the current version (0.6.10) only 0 (success) or 1 (fail) can be returned. It has to be improved in the future.

I also had the problem you mention (devices names that can change). You should use either LVM or devices entries in /dev/disk/by-label or /dev/disk/by-uuid since the name of the device will not change (as long as you don't have multiple filesystems with the same label / uuid)

Posts: 10
Joined: Mon Jun 14, 2010 9:00 pm

Re: Exit codes

Postby floor9 » Thu Jun 24, 2010 5:23 pm

I'll look into that, thanks. There's no reason why my script can't handle most of the error checking on its own, but I figured there's no point in re-inventing the wheel if FSArchiver is already doing the job.

Return to “How to use FSArchiver”

Who is online

Users browsing this forum: No registered users and 1 guest