File manager - Edit - /usr/share/doc/restic/html/050_restore.html
Back
<!DOCTYPE html> <html class="writer-html5" lang="en" > <head> <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Restoring from backup — restic 0.12.1 documentation</title> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <link rel="stylesheet" href="_static/css/restic.css" type="text/css" /> <link rel="shortcut icon" href="_static/favicon.ico"/> <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> <script src="_static/doctools.js"></script> <script src="_static/js/theme.js"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> <link rel="next" title="Removing backup snapshots" href="060_forget.html" /> <link rel="prev" title="Working with repositories" href="045_working_with_repos.html" /> </head> <body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > <a href="index.html" class="icon icon-home"> restic <img src="_static/logo.png" class="logo" alt="Logo"/> </a> <div class="version"> 0.12.1 </div> <div role="search"> <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="010_introduction.html">Introduction</a></li> <li class="toctree-l1"><a class="reference internal" href="020_installation.html">Installation</a></li> <li class="toctree-l1"><a class="reference internal" href="030_preparing_a_new_repo.html">Preparing a new repository</a></li> <li class="toctree-l1"><a class="reference internal" href="040_backup.html">Backing up</a></li> <li class="toctree-l1"><a class="reference internal" href="045_working_with_repos.html">Working with repositories</a></li> <li class="toctree-l1 current"><a class="current reference internal" href="#">Restoring from backup</a><ul> <li class="toctree-l2"><a class="reference internal" href="#restoring-from-a-snapshot">Restoring from a snapshot</a></li> <li class="toctree-l2"><a class="reference internal" href="#restore-using-mount">Restore using mount</a></li> <li class="toctree-l2"><a class="reference internal" href="#printing-files-to-stdout">Printing files to stdout</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="060_forget.html">Removing backup snapshots</a></li> <li class="toctree-l1"><a class="reference internal" href="070_encryption.html">Encryption</a></li> <li class="toctree-l1"><a class="reference internal" href="075_scripting.html">Scripting</a></li> <li class="toctree-l1"><a class="reference internal" href="080_examples.html">Examples</a></li> <li class="toctree-l1"><a class="reference internal" href="090_participating.html">Participating</a></li> <li class="toctree-l1"><a class="reference internal" href="100_references.html">References</a></li> <li class="toctree-l1"><a class="reference internal" href="110_talks.html">Talks</a></li> <li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li> <li class="toctree-l1"><a class="reference internal" href="manual_rest.html">Manual</a></li> <li class="toctree-l1"><a class="reference internal" href="developer_information.html">Developer Information</a></li> </ul> </div> </div> </nav> <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="index.html">restic</a> </nav> <div class="wy-nav-content"> <div class="rst-content"> <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> <li><a href="index.html" class="icon icon-home"></a> »</li> <li>Restoring from backup</li> <li class="wy-breadcrumbs-aside"> <a href="_sources/050_restore.rst.txt" rel="nofollow"> View page source</a> </li> </ul> <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> <section id="restoring-from-backup"> <h1>Restoring from backup<a class="headerlink" href="#restoring-from-backup" title="Permalink to this headline">¶</a></h1> <section id="restoring-from-a-snapshot"> <h2>Restoring from a snapshot<a class="headerlink" href="#restoring-from-a-snapshot" title="Permalink to this headline">¶</a></h2> <p>Restoring a snapshot is as easy as it sounds, just use the following command to restore the contents of the latest snapshot to <code class="docutils literal notranslate"><span class="pre">/tmp/restore-work</span></code>:</p> <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>restic -r /srv/restic-repo restore <span class="m">79766175</span> --target /tmp/restore-work <span class="go">enter password for repository:</span> <span class="go">restoring <Snapshot of [/home/user/work] at 2015-05-08 21:40:19.884408621 +0200 CEST> to /tmp/restore-work</span> </pre></div> </div> <p>Use the word <code class="docutils literal notranslate"><span class="pre">latest</span></code> to restore the last backup. You can also combine <code class="docutils literal notranslate"><span class="pre">latest</span></code> with the <code class="docutils literal notranslate"><span class="pre">--host</span></code> and <code class="docutils literal notranslate"><span class="pre">--path</span></code> filters to choose the last backup for a specific host, path or both.</p> <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>restic -r /srv/restic-repo restore latest --target /tmp/restore-art --path <span class="s2">"/home/art"</span> --host luigi <span class="go">enter password for repository:</span> <span class="go">restoring <Snapshot of [/home/art] at 2015-05-08 21:45:17.884408621 +0200 CEST> to /tmp/restore-art</span> </pre></div> </div> <p>Use <code class="docutils literal notranslate"><span class="pre">--exclude</span></code> and <code class="docutils literal notranslate"><span class="pre">--include</span></code> to restrict the restore to a subset of files in the snapshot. For example, to restore a single file:</p> <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>restic -r /srv/restic-repo restore <span class="m">79766175</span> --target /tmp/restore-work --include /work/foo <span class="go">enter password for repository:</span> <span class="go">restoring <Snapshot of [/home/user/work] at 2015-05-08 21:40:19.884408621 +0200 CEST> to /tmp/restore-work</span> </pre></div> </div> <p>This will restore the file <code class="docutils literal notranslate"><span class="pre">foo</span></code> to <code class="docutils literal notranslate"><span class="pre">/tmp/restore-work/work/foo</span></code>.</p> <p>You can use the command <code class="docutils literal notranslate"><span class="pre">restic</span> <span class="pre">ls</span> <span class="pre">latest</span></code> or <code class="docutils literal notranslate"><span class="pre">restic</span> <span class="pre">find</span> <span class="pre">foo</span></code> to find the path to the file within the snapshot. This path you can then pass to <code class="docutils literal notranslate"><span class="pre">--include</span></code> in verbatim to only restore the single file or directory.</p> <p>There are case insensitive variants of <code class="docutils literal notranslate"><span class="pre">--exclude</span></code> and <code class="docutils literal notranslate"><span class="pre">--include</span></code> called <code class="docutils literal notranslate"><span class="pre">--iexclude</span></code> and <code class="docutils literal notranslate"><span class="pre">--iinclude</span></code>. These options will behave the same way but ignore the casing of paths.</p> </section> <section id="restore-using-mount"> <h2>Restore using mount<a class="headerlink" href="#restore-using-mount" title="Permalink to this headline">¶</a></h2> <p>Browsing your backup as a regular file system is also very easy. First, create a mount point such as <code class="docutils literal notranslate"><span class="pre">/mnt/restic</span></code> and then use the following command to serve the repository with FUSE:</p> <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>mkdir /mnt/restic <span class="gp">$ </span>restic -r /srv/restic-repo mount /mnt/restic <span class="go">enter password for repository:</span> <span class="go">Now serving /srv/restic-repo at /mnt/restic</span> <span class="go">When finished, quit with Ctrl-c or umount the mountpoint.</span> </pre></div> </div> <p>Mounting repositories via FUSE is only possible on Linux, macOS and FreeBSD. On Linux, the <code class="docutils literal notranslate"><span class="pre">fuse</span></code> kernel module needs to be loaded and the <code class="docutils literal notranslate"><span class="pre">fusermount</span></code> command needs to be in the <code class="docutils literal notranslate"><span class="pre">PATH</span></code>. On macOS, you need <a class="reference external" href="https://osxfuse.github.io/">FUSE for macOS</a>. On FreeBSD, you may need to install FUSE and load the kernel module (<code class="docutils literal notranslate"><span class="pre">kldload</span> <span class="pre">fuse</span></code>).</p> <p>Restic supports storage and preservation of hard links. However, since hard links exist in the scope of a filesystem by definition, restoring hard links from a fuse mount should be done by a program that preserves hard links. A program that does so is <code class="docutils literal notranslate"><span class="pre">rsync</span></code>, used with the option –hard-links.</p> </section> <section id="printing-files-to-stdout"> <h2>Printing files to stdout<a class="headerlink" href="#printing-files-to-stdout" title="Permalink to this headline">¶</a></h2> <p>Sometimes it’s helpful to print files to stdout so that other programs can read the data directly. This can be achieved by using the <cite>dump</cite> command, like this:</p> <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>restic -r /srv/restic-repo dump latest production.sql <span class="p">|</span> mysql </pre></div> </div> <p>If you have saved multiple different things into the same repo, the <code class="docutils literal notranslate"><span class="pre">latest</span></code> snapshot may not be the right one. For example, consider the following snapshots in a repo:</p> <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>restic -r /srv/restic-repo snapshots <span class="go">ID Date Host Tags Directory</span> <span class="go">----------------------------------------------------------------------</span> <span class="go">562bfc5e 2018-07-14 20:18:01 mopped /home/user/file1</span> <span class="go">bbacb625 2018-07-14 20:18:07 mopped /home/other/work</span> <span class="go">e922c858 2018-07-14 20:18:10 mopped /home/other/work</span> <span class="go">098db9d5 2018-07-14 20:18:13 mopped /production.sql</span> <span class="go">b62f46ec 2018-07-14 20:18:16 mopped /home/user/file1</span> <span class="go">1541acae 2018-07-14 20:18:18 mopped /home/other/work</span> <span class="go">----------------------------------------------------------------------</span> </pre></div> </div> <p>Here, restic would resolve <code class="docutils literal notranslate"><span class="pre">latest</span></code> to the snapshot <code class="docutils literal notranslate"><span class="pre">1541acae</span></code>, which does not contain the file we’d like to print at all (<code class="docutils literal notranslate"><span class="pre">production.sql</span></code>). In this case, you can pass restic the snapshot ID of the snapshot you like to restore:</p> <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>restic -r /srv/restic-repo dump 098db9d5 production.sql <span class="p">|</span> mysql </pre></div> </div> <p>Or you can pass restic a path that should be used for selecting the latest snapshot. The path must match the patch printed in the “Directory” column, e.g.:</p> <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>restic -r /srv/restic-repo dump --path /production.sql latest production.sql <span class="p">|</span> mysql </pre></div> </div> <p>It is also possible to <code class="docutils literal notranslate"><span class="pre">dump</span></code> the contents of a whole folder structure to stdout. To retain the information about the files and folders Restic will output the contents in the tar (default) or zip format:</p> <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>restic -r /srv/restic-repo dump latest /home/other/work > restore.tar </pre></div> </div> <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>restic -r /srv/restic-repo dump -a zip latest /home/other/work > restore.zip </pre></div> </div> </section> </section> </div> </div> <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> <a href="045_working_with_repos.html" class="btn btn-neutral float-left" title="Working with repositories" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> <a href="060_forget.html" class="btn btn-neutral float-right" title="Removing backup snapshots" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> <hr/> <div role="contentinfo"> <p>© Copyright 2024, restic authors.</p> </div> Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. </footer> </div> </div> </section> </div> <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); </script> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 8.2.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings