@Michael K: glob() will always return the results in alphanumeric order for the full pathname.

@Lorna: Wouldn’t it also make sense to wrap the patch files in begin and end transactions before passing it to the command line so that failures are rolled back safely?

Obviously in MySQL this will only work for InnoDB tables, and even then there is caveats, but your only other alternative is to take a database snapshot first.

I tend to use a similar method to you when doing my database patches but I’ve yet to find a light-weight recovery solution I’m really happy with.