• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500-V1.0.1.40_1.0.68/ap/gpl/timemachine/db-4.7.25.NC/docs/gsg_txn/JAVA/
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>Backup Procedures</title>
7    <link rel="stylesheet" href="gettingStarted.css" type="text/css" />
8    <meta name="generator" content="DocBook XSL Stylesheets V1.62.4" />
9    <link rel="home" href="index.html" title="Getting Started with Berkeley DB Transaction Processing" />
10    <link rel="up" href="filemanagement.html" title="Chapter��5.��Managing DB Files" />
11    <link rel="previous" href="filemanagement.html" title="Chapter��5.��Managing DB Files" />
12    <link rel="next" href="recovery.html" title="Recovery Procedures" />
13  </head>
14  <body>
15    <div class="navheader">
16      <table width="100%" summary="Navigation header">
17        <tr>
18          <th colspan="3" align="center">Backup Procedures</th>
19        </tr>
20        <tr>
21          <td width="20%" align="left"><a accesskey="p" href="filemanagement.html">Prev</a>��</td>
22          <th width="60%" align="center">Chapter��5.��Managing DB Files</th>
23          <td width="20%" align="right">��<a accesskey="n" href="recovery.html">Next</a></td>
24        </tr>
25      </table>
26      <hr />
27    </div>
28    <div class="sect1" lang="en" xml:lang="en">
29      <div class="titlepage">
30        <div>
31          <div>
32            <h2 class="title" style="clear: both"><a id="backuprestore"></a>Backup Procedures</h2>
33          </div>
34        </div>
35        <div></div>
36      </div>
37      <p>
38            <span class="emphasis"><em>Durability</em></span> is an important part of your
39            transactional guarantees. It means that once a transaction has been
40            successfully committed, your application will always see the results of that
41            transaction. 
42        </p>
43      <p>
44            Of course, no software algorithm can guarantee durability in the face of physical data loss.  Hard drives
45            can fail, and if you have not copied your data to locations other than your primary disk drives,
46            then you will lose data when those drives fail.  Therefore, in order to truly obtain a durability
47            guarantee, you need to ensure that any data stored on disk is backed up to secondary or alternative storage,
48            such as secondary disk drives, or offline tapes.
49        </p>
50      <p>
51            There are three different types of backups that you can
52            perform with DB databases and log files.  They are:
53        </p>
54      <div class="itemizedlist">
55        <ul type="disc">
56          <li>
57            <p>
58                    Offline backups
59                </p>
60            <p>
61                    This type of backup is perhaps the easiest to perform as it
62                    involves simply copying database and log files to an
63                    offline storage area. It also gives you a snapshot of the
64                    database at a fixed, known point in time. However, you
65                    cannot perform this type of a backup while you are performing 
66                    writes to the database.
67                </p>
68          </li>
69          <li>
70            <p>
71                    Hot backups
72                </p>
73            <p>
74                    This type of backup gives you a snapshot of your database.
75                    Since your application can be writing to the database at the time that the
76                    snapshot is being taken, you do not necessarily know what
77                    the exact state of the database is for that given snapshot.
78                </p>
79          </li>
80          <li>
81            <p>
82                    Incremental backups
83                </p>
84            <p>
85                    This type of backup refreshes a previously performed backup.
86                </p>
87          </li>
88        </ul>
89      </div>
90      <p>
91            Once you have performed a backup, you can
92            perform <span class="emphasis"><em>catastrophic recovery</em></span> to restore
93            your databases from the backup. See
94            <a href="recovery.html#catastrophicrecovery">Catastrophic Recovery</a>
95            for more information.
96        </p>
97      <p>
98            Note that you can also maintain a hot failover. See
99            <a href="hotfailover.html">Using Hot Failovers</a>
100            for more information.
101        </p>
102      <div class="sect2" lang="en" xml:lang="en">
103        <div class="titlepage">
104          <div>
105            <div>
106              <h3 class="title"><a id="copyutilities"></a>About Unix Copy Utilities</h3>
107            </div>
108          </div>
109          <div></div>
110        </div>
111        <p>
112
113               If you are copying database files you must copy databases atomically, 
114               in multiples of the database page size. In other words, the reads made by
115               the copy program must not be interleaved with writes by
116               other threads of control, and the copy program must read the
117               databases in multiples of the underlying database page size.
118               Generally, this is not a problem because operating systems
119               already make this guarantee and system utilities normally
120               read in power-of-2 sized chunks, which are larger than the
121               largest possible Berkeley DB database page size. 
122            </p>
123        <p>
124                On some platforms (most notably, some releases of Solaris), the copy utility (<tt class="literal">cp</tt>) was
125                implemented using the <tt class="function">mmap()</tt> system call rather than the
126                <tt class="function">read()</tt> system call. Because <tt class="function">mmap()</tt> did not make the same
127                guarantee of read atomicity as did <tt class="function">read()</tt>, the <tt class="literal">cp</tt> utility
128                could create corrupted copies of the databases. 
129            </p>
130        <p>
131                Also, some platforms have implementations of the <tt class="literal">tar</tt> utility that performs 10KB block
132                reads by default. Even when an output block size is specified, the utility will still not read the
133                underlying databases in multiples of the specified block size. Again, the result can be a corrupted backup.
134            </p>
135        <p>
136                To fix these problems, use the <tt class="literal">dd</tt> utility instead of <tt class="literal">cp</tt> or
137                <tt class="literal">tar</tt>. When you use <tt class="literal">dd</tt>, make sure you specify a block size that is
138                equal to, or an even multiple of, your database page size. Finally, if you plan to use a system
139                utility to copy database files, you may want to use a system call trace utility (for example, 
140                <tt class="literal">ktrace</tt> or <tt class="literal">truss</tt>) to make sure you are not using a I/O size that is
141                smaller than your database page size. You can also use these utilities to make sure the system utility is
142                not using a system call other than <tt class="function">read()</tt>.
143            </p>
144      </div>
145      <div class="sect2" lang="en" xml:lang="en">
146        <div class="titlepage">
147          <div>
148            <div>
149              <h3 class="title"><a id="standardbackup"></a>Offline Backups</h3>
150            </div>
151          </div>
152          <div></div>
153        </div>
154        <p>
155                To create an offline backup:
156            </p>
157        <div class="orderedlist">
158          <ol type="1">
159            <li>
160              <p>
161                        Commit or abort all on-going transactions.
162                    </p>
163            </li>
164            <li>
165              <p>
166                        Pause all database writes.
167                    </p>
168            </li>
169            <li>
170              <p>
171                        Force a checkpoint. See 
172                            <a href="filemanagement.html#checkpoints">Checkpoints</a>
173                        for details.
174                    </p>
175            </li>
176            <li>
177              <p>
178                        Copy all your database files to the backup location. 
179                        <span>
180                            Note that you can simply copy all of the database
181                            files, or you can determine which database files
182                            have been written during the lifetime of the current
183                            logs. To do this, use either the
184                                
185                                <span>
186                                    <tt class="methodname">Environment.getArchiveDatabases()</tt>,                                    
187                                    method
188                                </span>
189
190                                or use the <span><b class="command">db_archive</b></span>
191                                command with the <tt class="literal">-s</tt> option. 
192                        </span>
193                    </p>
194              <p>
195                        However, be aware that backing up just the modified databases only works if you have all of your
196                        log files. If you have been removing log files for any reason then using
197                                
198                                <span>
199                                    <tt class="methodname">getArchiveDatabases()</tt>,                                    
200                                </span>
201
202                        can result in an
203                        unrecoverable backup because you might not be notified of a database file that was modified. 
204                    </p>
205            </li>
206            <li>
207              <p>
208                        Copy the <span class="emphasis"><em>last</em></span> log file to your backup location.
209                        Your log files are named
210                        <tt class="literal">log.<span class="emphasis"><em>xxxxxxxxxx</em></span></tt>,
211                        where <span class="emphasis"><em>xxxxxxxxxx</em></span> is a
212                        sequential number. The last log file is the file
213                        with the highest number.
214                    </p>
215            </li>
216          </ol>
217        </div>
218      </div>
219      <div class="sect2" lang="en" xml:lang="en">
220        <div class="titlepage">
221          <div>
222            <div>
223              <h3 class="title"><a id="hotbackup"></a>Hot Backup</h3>
224            </div>
225          </div>
226          <div></div>
227        </div>
228        <p>
229                To create a hot backup, you do not have to stop database
230                operations. Transactions may be on-going and you can be writing
231                to your database at the time of the backup. However, this means
232                that you do not know exactly what the state of your database is
233                at the time of the backup.
234            </p>
235        <p>
236                You can use the <span><b class="command">db_hotbackup</b></span> command line utility to create a hot backup for you. This
237                utility will (optionally) run a checkpoint and the copy all necessary files to a target directory.
238            </p>
239        <p>
240                Alternatively, you can manually create a hot backup as follows:
241            </p>
242        <div class="orderedlist">
243          <ol type="1">
244            <li>
245              <p>
246                        Copy all your database files to the backup location. 
247                        <span>
248                            Note that you can simply copy all of the database
249                            files, or you can determine which database files
250                            have been written during the lifetime of the current
251                            logs. To do this, use either the
252                                
253                                <span>
254                                    <tt class="methodname">Environment.getArchiveDatabases()</tt>,                                    
255                                </span>
256
257                                or use the <span><b class="command">db_archive</b></span>
258                                command with the <tt class="literal">-s</tt> option. 
259                        </span>
260                    </p>
261            </li>
262            <li>
263              <p>
264                        Copy all logs to your backup location.
265                    </p>
266            </li>
267          </ol>
268        </div>
269        <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
270          <h3 class="title">Note</h3>
271          <p>
272                    It is important to copy your database files <span class="emphasis"><em>and
273                    then</em></span> your logs. In this way, 
274                    you can complete or roll back any database operations that were only partially completed 
275                    when you copied the databases. 
276                </p>
277        </div>
278      </div>
279      <div class="sect2" lang="en" xml:lang="en">
280        <div class="titlepage">
281          <div>
282            <div>
283              <h3 class="title"><a id="incrementalbackups"></a>Incremental Backups</h3>
284            </div>
285          </div>
286          <div></div>
287        </div>
288        <p>
289                Once you have created a full backup (that is, either a
290                offline or hot backup), you can create incremental backups.  
291                To do this, simply copy all of your currently existing log
292                files to your backup location. 
293            </p>
294        <p>
295                Incremental backups do not require you to run a checkpoint
296                or to cease database write operations. 
297            </p>
298        <p>
299                When you are working with incremental backups, remember
300                that the greater the number of log files contained in 
301                your backup, the longer recovery will take.  
302                You should run full backups
303                on some interval, and then do incremental backups on a shorter interval.
304                How frequently you need to run a full backup
305                is determined by the rate at which your databases change and
306                how sensitive your application is to lengthy recoveries
307                (should one be required).
308              </p>
309        <p>
310                You can also shorten recovery time by running recovery against the backup as you take each incremental
311                backup.  Running recovery as you go means that there will be less work for DB to do if you should
312                ever need to restore your environment from the backup.
313            </p>
314      </div>
315    </div>
316    <div class="navfooter">
317      <hr />
318      <table width="100%" summary="Navigation footer">
319        <tr>
320          <td width="40%" align="left"><a accesskey="p" href="filemanagement.html">Prev</a>��</td>
321          <td width="20%" align="center">
322            <a accesskey="u" href="filemanagement.html">Up</a>
323          </td>
324          <td width="40%" align="right">��<a accesskey="n" href="recovery.html">Next</a></td>
325        </tr>
326        <tr>
327          <td width="40%" align="left" valign="top">Chapter��5.��Managing DB Files��</td>
328          <td width="20%" align="center">
329            <a accesskey="h" href="index.html">Home</a>
330          </td>
331          <td width="40%" align="right" valign="top">��Recovery Procedures</td>
332        </tr>
333      </table>
334    </div>
335  </body>
336</html>
337