For future reference, in addition to your database, keep a plaintext backup that you refresh periodically. (Just write a script to open your dbm, walk the keys and dump it in a plaintext format.)

That way if you are dealing with a problem like this, you have the option of writing a script to take the plaintext backup and recreate the database. Actually you should do this before you run into trouble, and try the dump/undump utility out. (That way you can find that, for instance, your plaintext format assumes no returns in the data, but there are returns...)

And a note for the future. What happened to you illustrates why in a switchover people should ALWAYS do testing (which should have caught that your application had problems) and also keep the old server around (so that people can figure out how to rescue stuff that broke).

Also a random tip. If you are using this in a CGI environment, be warned that the widely used locking technique of calling flock on the dbm does not work. (This used to be the documented approach, and appeared, for instance, in the old Cookbook.) Use either the native locking facilities in BerkeleyDB or use DB_File::Lock instead. (If you are not using locking, of course, then you should. The consequences of not doing so include file corruption and loss of data.)


In reply to Re: Berkley DB version problems; work stoppage! by tilly
in thread Berkley DB version problems; work stoppage! by kleucht

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.