codekingpro/portable-devtools
115k
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"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>pg_verifybackup</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-pgrestore.html" title="pg_restore" /><link rel="next" href="app-psql.html" title="psql" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">pg_verifybackup</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-pgrestore.html" title="pg_restore">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><th width="60%" align="center">PostgreSQL Client Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-psql.html" title="psql">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-PGVERIFYBACKUP"><div class="titlepage"></div><a id="id-1.9.4.19.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">pg_verifybackup</span></span></h2><p>pg_verifybackup — verify the integrity of a base backup of a3 <span class="productname">PostgreSQL</span> cluster</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.4.19.4.1"><code class="command">pg_verifybackup</code> [<em class="replaceable"><code>option</code></em>...]</p></div></div><div class="refsect1" id="id-1.9.4.19.5"><h2>Description</h2><p>4 <span class="application">pg_verifybackup</span> is used to check the5 integrity of a database cluster backup taken using6 <code class="command">pg_basebackup</code> against a7 <code class="literal">backup_manifest</code> generated by the server at the time8 of the backup. The backup must be stored in the "plain"9 format; a "tar" format backup can be checked after extracting it.10 </p><p>11 It is important to note that the validation which is performed by12 <span class="application">pg_verifybackup</span> does not and cannot include13 every check which will be performed by a running server when attempting14 to make use of the backup. Even if you use this tool, you should still15 perform test restores and verify that the resulting databases work as16 expected and that they appear to contain the correct data. However,17 <span class="application">pg_verifybackup</span> can detect many problems18 that commonly occur due to storage problems or user error.19 </p><p>20 Backup verification proceeds in four stages. First,21 <code class="literal">pg_verifybackup</code> reads the22 <code class="literal">backup_manifest</code> file. If that file23 does not exist, cannot be read, is malformed, or fails verification24 against its own internal checksum, <code class="literal">pg_verifybackup</code>25 will terminate with a fatal error.26 </p><p>27 Second, <code class="literal">pg_verifybackup</code> will attempt to verify that28 the data files currently stored on disk are exactly the same as the data29 files which the server intended to send, with some exceptions that are30 described below. Extra and missing files will be detected, with a few31 exceptions. This step will ignore the presence or absence of, or any32 modifications to, <code class="literal">postgresql.auto.conf</code>,33 <code class="literal">standby.signal</code>, and <code class="literal">recovery.signal</code>,34 because it is expected that these files may have been created or modified35 as part of the process of taking the backup. It also won't complain about36 a <code class="literal">backup_manifest</code> file in the target directory or37 about anything inside <code class="literal">pg_wal</code>, even though these38 files won't be listed in the backup manifest. Only files are checked;39 the presence or absence of directories is not verified, except40 indirectly: if a directory is missing, any files it should have contained41 will necessarily also be missing.42 </p><p>43 Next, <code class="literal">pg_verifybackup</code> will checksum all the files,44 compare the checksums against the values in the manifest, and emit errors45 for any files for which the computed checksum does not match the46 checksum stored in the manifest. This step is not performed for any files47 which produced errors in the previous step, since they are already known48 to have problems. Files which were ignored in the previous step are also49 ignored in this step.50 </p><p>51 Finally, <code class="literal">pg_verifybackup</code> will use the manifest to52 verify that the write-ahead log records which will be needed to recover53 the backup are present and that they can be read and parsed. The54 <code class="literal">backup_manifest</code> contains information about which55 write-ahead log records will be needed, and56 <code class="literal">pg_verifybackup</code> will use that information to57 invoke <code class="literal">pg_waldump</code> to parse those write-ahead log58 records. The <code class="literal">--quiet</code> flag will be used, so that59 <code class="literal">pg_waldump</code> will only report errors, without producing60 any other output. While this level of verification is sufficient to61 detect obvious problems such as a missing file or one whose internal62 checksums do not match, they aren't extensive enough to detect every63 possible problem that might occur when attempting to recover. For64 instance, a server bug that produces write-ahead log records that have65 the correct checksums but specify nonsensical actions can't be detected66 by this method.67 </p><p>68 Note that if extra WAL files which are not required to recover the backup69 are present, they will not be checked by this tool, although70 a separate invocation of <code class="literal">pg_waldump</code> could be used for71 that purpose. Also note that WAL verification is version-specific: you72 must use the version of <code class="literal">pg_verifybackup</code>, and thus of73 <code class="literal">pg_waldump</code>, which pertains to the backup being checked.74 In contrast, the data file integrity checks should work with any version75 of the server that generates a <code class="literal">backup_manifest</code> file.76 </p></div><div class="refsect1" id="id-1.9.4.19.6"><h2>Options</h2><p>77 <span class="application">pg_verifybackup</span> accepts the following78 command-line arguments:79 80 </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-e</code><br /></span><span class="term"><code class="option">--exit-on-error</code></span></dt><dd><p>81 Exit as soon as a problem with the backup is detected. If this option82 is not specified, <code class="literal">pg_verifybackup</code> will continue83 checking the backup even after a problem has been detected, and will84 report all problems detected as errors.85 </p></dd><dt><span class="term"><code class="option">-i <em class="replaceable"><code>path</code></em></code><br /></span><span class="term"><code class="option">--ignore=<em class="replaceable"><code>path</code></em></code></span></dt><dd><p>86 Ignore the specified file or directory, which should be expressed87 as a relative path name, when comparing the list of data files88 actually present in the backup to those listed in the89 <code class="literal">backup_manifest</code> file. If a directory is90 specified, this option affects the entire subtree rooted at that91 location. Complaints about extra files, missing files, file size92 differences, or checksum mismatches will be suppressed if the93 relative path name matches the specified path name. This option94 can be specified multiple times.95 </p></dd><dt><span class="term"><code class="option">-m <em class="replaceable"><code>path</code></em></code><br /></span><span class="term"><code class="option">--manifest-path=<em class="replaceable"><code>path</code></em></code></span></dt><dd><p>96 Use the manifest file at the specified path, rather than one located97 in the root of the backup directory.98 </p></dd><dt><span class="term"><code class="option">-n</code><br /></span><span class="term"><code class="option">--no-parse-wal</code></span></dt><dd><p>99 Don't attempt to parse write-ahead log data that will be needed100 to recover from this backup.101 </p></dd><dt><span class="term"><code class="option">-P</code><br /></span><span class="term"><code class="option">--progress</code></span></dt><dd><p>102 Enable progress reporting. Turning this on will deliver a progress103 report while verifying checksums.104 </p><p>105 This option cannot be used together with the option106 <code class="option">--quiet</code>.107 </p></dd><dt><span class="term"><code class="option">-q</code><br /></span><span class="term"><code class="option">--quiet</code></span></dt><dd><p>108 Don't print anything when a backup is successfully verified.109 </p></dd><dt><span class="term"><code class="option">-s</code><br /></span><span class="term"><code class="option">--skip-checksums</code></span></dt><dd><p>110 Do not verify data file checksums. The presence or absence of111 files and the sizes of those files will still be checked. This is112 much faster, because the files themselves do not need to be read.113 </p></dd><dt><span class="term"><code class="option">-w <em class="replaceable"><code>path</code></em></code><br /></span><span class="term"><code class="option">--wal-directory=<em class="replaceable"><code>path</code></em></code></span></dt><dd><p>114 Try to parse WAL files stored in the specified directory, rather than115 in <code class="literal">pg_wal</code>. This may be useful if the backup is116 stored in a separate location from the WAL archive.117 </p></dd></dl></div><p>118 </p><p>119 Other options are also available:120 121 </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>122 Print the <span class="application">pg_verifybackup</span> version and exit.123 </p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>124 Show help about <span class="application">pg_verifybackup</span> command125 line arguments, and exit.126 </p></dd></dl></div><p>127 </p></div><div class="refsect1" id="id-1.9.4.19.7"><h2>Examples</h2><p>128 To create a base backup of the server at <code class="literal">mydbserver</code> and129 verify the integrity of the backup:130</p><pre class="screen">131<code class="prompt">$</code> <strong class="userinput"><code>pg_basebackup -h mydbserver -D /usr/local/pgsql/data</code></strong>132<code class="prompt">$</code> <strong class="userinput"><code>pg_verifybackup /usr/local/pgsql/data</code></strong>133</pre><p>134 </p><p>135 To create a base backup of the server at <code class="literal">mydbserver</code>, move136 the manifest somewhere outside the backup directory, and verify the137 backup:138</p><pre class="screen">139<code class="prompt">$</code> <strong class="userinput"><code>pg_basebackup -h mydbserver -D /usr/local/pgsql/backup1234</code></strong>140<code class="prompt">$</code> <strong class="userinput"><code>mv /usr/local/pgsql/backup1234/backup_manifest /my/secure/location/backup_manifest.1234</code></strong>141<code class="prompt">$</code> <strong class="userinput"><code>pg_verifybackup -m /my/secure/location/backup_manifest.1234 /usr/local/pgsql/backup1234</code></strong>142</pre><p>143 </p><p>144 To verify a backup while ignoring a file that was added manually to the145 backup directory, and also skipping checksum verification:146</p><pre class="screen">147<code class="prompt">$</code> <strong class="userinput"><code>pg_basebackup -h mydbserver -D /usr/local/pgsql/data</code></strong>148<code class="prompt">$</code> <strong class="userinput"><code>edit /usr/local/pgsql/data/note.to.self</code></strong>149<code class="prompt">$</code> <strong class="userinput"><code>pg_verifybackup --ignore=note.to.self --skip-checksums /usr/local/pgsql/data</code></strong>150</pre></div><div class="refsect1" id="id-1.9.4.19.8"><h2>See Also</h2><span class="simplelist"><a class="xref" href="app-pgbasebackup.html" title="pg_basebackup"><span class="refentrytitle"><span class="application">pg_basebackup</span></span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-pgrestore.html" title="pg_restore">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-psql.html" title="psql">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">pg_restore</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">psql</span></td></tr></table></div></body></html>