#7 Halt if precondition fails


Hey guys. thanks for the great little tool.

I have one feature request -- it would be nice if duply would check the return code of the precondition (pre) to determine if it should continue with the backup. If the precondition returns something nonzero (failure), duply would abort. If the precondition does not return something nonzero, duply would continue. This would allow the user to write code like the following.


# If the backup drive is not already mounted, abort.
if [ ! -d /media/backup_drive ]; then
exit 1;

What do you think? Does this make sense, or would you argue that there is a better way to do this?



  • ede

    ede - 2011-02-06

    move it to the featreq tracker... duly noted but not high on my priority list, ede

  • Comment has been marked as spam. 

    You can see all pending comments posted by this user  here

    Anonymous - 2012-04-24

    That'd be a most useful feature for me.

    I backup to a CIFS-mounted storage device under /mnt/storage, which from time to time isn't mounted. At the time being I have no possibility but a wrapper script to tell Duply it should stop, when storage is not mounted.

    Last edit: Anonymous 2015-01-02
  • ede

    ede - 2012-04-24

    i have a similar setup for which i do something like

    mount | grep -q "/media/backup_drive" && duply ...

    i already thought about implementing checking return codes. in case it'll come it will be voluntarily (a cmd switch or a batch cmd modificator) to ensure that old duply setups with stupid pre scripts wont break.


  • Jörg

    Jörg - 2012-07-20

    I would like to add support for this feature request. I was actually disappointed to find out that duply does not work this way.

  • ede

    ede - 2012-07-20

    hey joerg,

    any contribution is welcome. you make sure that the patch is in line with the points of my previous post though.


  • Kurt Huwig

    Kurt Huwig - 2013-04-03

    Instead of running

    duply X backup

    you can run

    duply X pre && duply X bkp && duply X post

  • Pieter

    Pieter - 2014-01-16

    My contribution:
    I used a new bacht cmd, constraint, it works the same as the pre script, but if it exits with a non-zero code duplicity exits and none of the subsequent commands wont run.

    I think this solution is in line with the points mentioned by ede.

  • ede

    ede - 2014-01-17

    hey Pieter,

    appreciate your effort very much! but actually i'd rather implement it as batch modificators like and/or e.g.


    this would make bkp run only if pre successes but post would be executed all the time. so the modificator just impacts the next batch action.

    an alternative approach without words would be using +/- same example as above


    not sure if this is really more intuitive.

    your approach brings up an interesting point though. you introduced an additional script name and i wonder now if simply trying to look if 'unknown' batch cmds actually exist as script in the profile folder would make duply more scriptable. this way you could easily write then


    provided you've got a file dumpdbs in your profile. but that's just an idea probably not worth the effort.


  • Pieter

    Pieter - 2014-01-17

    Hi ede,

    Below a version using the and command modifier. If the previous command exits with with a non-zero value the next command does not run. The skipt command exits with a 1, so that you can do:


    if pre fails now both bkp and post will not run.

    an and command at the beginning of the batch should always give a success.

  • ede

    ede - 2014-01-19

    hey Pieter,

    better and simpler, don't you think?
    implementation-wise the switch case / if conditions in the main loop should go into one routine only. also 'or' should be implemented at the same time.

    but i am still not sure about using and/or commands. seems unintuitive (as they are no action commands as such). different separators such as '+/-' instead of '_' seem ugly but would fit the bill of a conditional separator much better. so
    would become
    pre+bkp-post .
    unfortunately && and || would raise to many user errors as we could expect lot's of people not to escape them properly.
    what do you think is better/possible?


  • Pieter

    Pieter - 2014-01-19

    Hi ede,

    Yes this is much better! Implementing the or is no problem, but i'm not sure how you would want to implement the conditions in one routine. As we need to be in two loops, the first for the and condition and then in the next loop we skip the command.

    Personally I like the and/or commands more than the +/-, it reads more natural and is also clearer for me especially in the case with or/-.


  • ede

    ede - 2014-03-10
    • status: open --> closed
    • Group: --> Next Release (example)

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks