| 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 4 | <head> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| 6 | <title>Recovery and filesystem operations</title> |
| 7 | <link rel="stylesheet" href="gettingStarted.css" type="text/css" /> |
| 8 | <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> |
| 9 | <link rel="start" href="index.html" title="Berkeley DB Programmer's Reference Guide" /> |
| 10 | <link rel="up" href="transapp.html" title="Chapter 11. Berkeley DB Transactional Data Store Applications" /> |
| 11 | <link rel="prev" href="transapp_journal.html" title="Using Recovery on Journaling Filesystems" /> |
| 12 | <link rel="next" href="transapp_reclimit.html" title="Berkeley DB recoverability" /> |
| 13 | </head> |
| 14 | <body> |
| 15 | <div xmlns="" class="navheader"> |
| 16 | <div class="libver"> |
| 17 | <p>Library Version 11.2.5.3</p> |
| 18 | </div> |
| 19 | <table width="100%" summary="Navigation header"> |
| 20 | <tr> |
| 21 | <th colspan="3" align="center">Recovery and filesystem operations</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="transapp_journal.html">Prev</a> </td> |
| 25 | <th width="60%" align="center">Chapter 11. |
| 26 | Berkeley DB Transactional Data Store Applications |
| 27 | </th> |
| 28 | <td width="20%" align="right"> <a accesskey="n" href="transapp_reclimit.html">Next</a></td> |
| 29 | </tr> |
| 30 | </table> |
| 31 | <hr /> |
| 32 | </div> |
| 33 | <div class="sect1" lang="en" xml:lang="en"> |
| 34 | <div class="titlepage"> |
| 35 | <div> |
| 36 | <div> |
| 37 | <h2 class="title" style="clear: both"><a id="transapp_filesys"></a>Recovery and filesystem operations</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <p> |
| 42 | The Berkeley DB API supports creating, removing and renaming files. |
| 43 | Creating files is supported by the <a href="../api_reference/C/dbopen.html" class="olink">DB->open()</a> method. Removing files is |
| 44 | supported by the <a href="../api_reference/C/envdbremove.html" class="olink">DB_ENV->dbremove()</a> and <a href="../api_reference/C/dbremove.html" class="olink">DB->remove()</a> methods. Renaming files |
| 45 | is supported by the <a href="../api_reference/C/envdbrename.html" class="olink">DB_ENV->dbrename()</a> and <a href="../api_reference/C/dbrename.html" class="olink">DB->rename()</a> methods. (There are |
| 46 | two methods for removing and renaming files because one of the methods |
| 47 | is transactionally protected and one is not.) |
| 48 | </p> |
| 49 | <p> |
| 50 | Berkeley DB does not permit specifying the <a href="../api_reference/C/dbopen.html#open_DB_TRUNCATE" class="olink">DB_TRUNCATE</a> flag when |
| 51 | opening a file in a transaction-protected environment. This is an |
| 52 | implicit file deletion, but one that does not always require the same |
| 53 | operating system file permissions as deleting and creating a file do. |
| 54 | </p> |
| 55 | <p> |
| 56 | If you have changed the name of a file or deleted it outside of the |
| 57 | Berkeley DB library (for example, you explicitly removed a file using |
| 58 | your normal operating system utilities), then it is possible that |
| 59 | recovery will not be able to find a database to which the log refers. |
| 60 | In this case, the <a href="../api_reference/C/db_recover.html" class="olink">db_recover</a> utility will produce a warning message, saying |
| 61 | it was unable to locate a file it expected to find. This message is |
| 62 | only a warning because the file may have been subsequently deleted as |
| 63 | part of normal database operations before the failure occurred, so is |
| 64 | not necessarily a problem. |
| 65 | </p> |
| 66 | <p> |
| 67 | Generally, any filesystem operations that are performed outside the |
| 68 | Berkeley DB interface should be performed at the same time as making a |
| 69 | snapshot of the database. To perform filesystem operations correctly, |
| 70 | do the following: |
| 71 | </p> |
| 72 | <div class="orderedlist"> |
| 73 | <ol type="1"> |
| 74 | <li> |
| 75 | <p>Cleanly shut down database operations.</p> |
| 76 | <p>To shut down database operations cleanly, all applications accessing |
| 77 | the database environment must be shut down and a transaction checkpoint |
| 78 | must be taken. If the applications are not implemented so they can be |
| 79 | shut down gracefully (that is, closing all references to the database |
| 80 | environment), recovery must be performed after all applications have |
| 81 | been killed to ensure that the underlying databases are consistent on |
| 82 | disk.</p> |
| 83 | </li> |
| 84 | <li>Perform the filesystem operations; for example, remove or rename one or |
| 85 | more files.</li> |
| 86 | <li> |
| 87 | <p>Make an archival snapshot of the database.</p> |
| 88 | <p>Although this step is not strictly necessary, it is strongly |
| 89 | recommended. If this step is not performed, recovery from catastrophic |
| 90 | failure will require that recovery first be performed up to the time of |
| 91 | the filesystem operations, the filesystem operations be redone, and then |
| 92 | recovery be performed from the filesystem operations forward.</p> |
| 93 | </li> |
| 94 | <li>Restart the database applications.</li> |
| 95 | </ol> |
| 96 | </div> |
| 97 | </div> |
| 98 | <div class="navfooter"> |
| 99 | <hr /> |
| 100 | <table width="100%" summary="Navigation footer"> |
| 101 | <tr> |
| 102 | <td width="40%" align="left"><a accesskey="p" href="transapp_journal.html">Prev</a> </td> |
| 103 | <td width="20%" align="center"> |
| 104 | <a accesskey="u" href="transapp.html">Up</a> |
| 105 | </td> |
| 106 | <td width="40%" align="right"> <a accesskey="n" href="transapp_reclimit.html">Next</a></td> |
| 107 | </tr> |
| 108 | <tr> |
| 109 | <td width="40%" align="left" valign="top">Using Recovery on Journaling Filesystems </td> |
| 110 | <td width="20%" align="center"> |
| 111 | <a accesskey="h" href="index.html">Home</a> |
| 112 | </td> |
| 113 | <td width="40%" align="right" valign="top"> Berkeley DB recoverability</td> |
| 114 | </tr> |
| 115 | </table> |
| 116 | </div> |
| 117 | </body> |
| 118 | </html> |