File manager - Edit - /home/newsbmcs.com/public_html/static/img/logo/060_forget.html.tar
Back
usr/share/doc/restic/html/060_forget.html 0000644 00000104664 15030553574 0014244 0 ustar 00 <!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>Removing backup snapshots — 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="Encryption" href="070_encryption.html" /> <link rel="prev" title="Restoring from backup" href="050_restore.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"><a class="reference internal" href="050_restore.html">Restoring from backup</a></li> <li class="toctree-l1 current"><a class="current reference internal" href="#">Removing backup snapshots</a><ul> <li class="toctree-l2"><a class="reference internal" href="#remove-a-single-snapshot">Remove a single snapshot</a></li> <li class="toctree-l2"><a class="reference internal" href="#removing-snapshots-according-to-a-policy">Removing snapshots according to a policy</a></li> <li class="toctree-l2"><a class="reference internal" href="#customize-pruning">Customize pruning</a></li> </ul> </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>Removing backup snapshots</li> <li class="wy-breadcrumbs-aside"> <a href="_sources/060_forget.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="removing-backup-snapshots"> <h1>Removing backup snapshots<a class="headerlink" href="#removing-backup-snapshots" title="Permalink to this headline">¶</a></h1> <p>All backup space is finite, so restic allows removing old snapshots. This can be done either manually (by specifying a snapshot ID to remove) or by using a policy that describes which snapshots to forget. For all remove operations, two commands need to be called in sequence: <code class="docutils literal notranslate"><span class="pre">forget</span></code> to remove a snapshot and <code class="docutils literal notranslate"><span class="pre">prune</span></code> to actually remove the data that was referenced by the snapshot from the repository. This can be automated with the <code class="docutils literal notranslate"><span class="pre">--prune</span></code> option of the <code class="docutils literal notranslate"><span class="pre">forget</span></code> command, which runs <code class="docutils literal notranslate"><span class="pre">prune</span></code> automatically if snapshots have been removed.</p> <p>Pruning snapshots can be a time-consuming process, depending on the amount of snapshots and data to process. During a prune operation, the repository is locked and backups cannot be completed. Please plan your pruning so that there’s time to complete it and it doesn’t interfere with regular backup runs.</p> <p>It is advisable to run <code class="docutils literal notranslate"><span class="pre">restic</span> <span class="pre">check</span></code> after pruning, to make sure you are alerted, should the internal data structures of the repository be damaged.</p> <section id="remove-a-single-snapshot"> <h2>Remove a single snapshot<a class="headerlink" href="#remove-a-single-snapshot" title="Permalink to this headline">¶</a></h2> <p>The command <code class="docutils literal notranslate"><span class="pre">snapshots</span></code> can be used to list all snapshots in a repository like this:</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">enter password for repository:</span> <span class="go">ID Date Host Tags Directory</span> <span class="go">----------------------------------------------------------------------</span> <span class="go">40dc1520 2015-05-08 21:38:30 kasimir /home/user/work</span> <span class="go">79766175 2015-05-08 21:40:19 kasimir /home/user/work</span> <span class="go">bdbd3439 2015-05-08 21:45:17 luigi /home/art</span> <span class="go">590c8fc8 2015-05-08 21:47:38 kazik /srv</span> <span class="go">9f0bc19e 2015-05-08 21:46:11 luigi /srv</span> </pre></div> </div> <p>In order to remove the snapshot of <code class="docutils literal notranslate"><span class="pre">/home/art</span></code>, use the <code class="docutils literal notranslate"><span class="pre">forget</span></code> command and specify the snapshot ID on the command line:</p> <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>restic -r /srv/restic-repo forget bdbd3439 <span class="go">enter password for repository:</span> <span class="go">removed snapshot bdbd3439</span> </pre></div> </div> <p>Afterwards this snapshot is removed:</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">enter password for repository:</span> <span class="go">ID Date Host Tags Directory</span> <span class="go">----------------------------------------------------------------------</span> <span class="go">40dc1520 2015-05-08 21:38:30 kasimir /home/user/work</span> <span class="go">79766175 2015-05-08 21:40:19 kasimir /home/user/work</span> <span class="go">590c8fc8 2015-05-08 21:47:38 kazik /srv</span> <span class="go">9f0bc19e 2015-05-08 21:46:11 luigi /srv</span> </pre></div> </div> <p>But the data that was referenced by files in this snapshot is still stored in the repository. To cleanup unreferenced data, the <code class="docutils literal notranslate"><span class="pre">prune</span></code> command must be run:</p> <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>restic -r /srv/restic-repo prune <span class="go">enter password for repository:</span> <span class="go">repository 33002c5e opened successfully, password is correct</span> <span class="go">loading all snapshots...</span> <span class="go">loading indexes...</span> <span class="go">finding data that is still in use for 4 snapshots</span> <span class="gp">[0:00] 100.00% </span><span class="m">4</span> / <span class="m">4</span> snapshots <span class="go">searching used packs...</span> <span class="go">collecting packs for deletion and repacking</span> <span class="gp">[0:00] 100.00% </span><span class="m">5</span> / <span class="m">5</span> packs processed <span class="go">to repack: 69 blobs / 1.078 MiB</span> <span class="go">this removes 67 blobs / 1.047 MiB</span> <span class="go">to delete: 7 blobs / 25.726 KiB</span> <span class="go">total prune: 74 blobs / 1.072 MiB</span> <span class="go">remaining: 16 blobs / 38.003 KiB</span> <span class="go">unused size after prune: 0 B (0.00% of remaining size)</span> <span class="go">repacking packs</span> <span class="gp">[0:00] 100.00% </span><span class="m">2</span> / <span class="m">2</span> packs repacked <span class="go">rebuilding index</span> <span class="gp">[0:00] 100.00% </span><span class="m">3</span> / <span class="m">3</span> packs processed <span class="go">deleting obsolete index files</span> <span class="gp">[0:00] 100.00% </span><span class="m">3</span> / <span class="m">3</span> files deleted <span class="go">removing 3 old packs</span> <span class="gp">[0:00] 100.00% </span><span class="m">3</span> / <span class="m">3</span> files deleted <span class="go">done</span> </pre></div> </div> <p>Afterwards the repository is smaller.</p> <p>You can automate this two-step process by using the <code class="docutils literal notranslate"><span class="pre">--prune</span></code> switch to <code class="docutils literal notranslate"><span class="pre">forget</span></code>:</p> <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>restic forget --keep-last <span class="m">1</span> --prune <span class="go">snapshots for host mopped, directories /home/user/work:</span> <span class="go">keep 1 snapshots:</span> <span class="go">ID Date Host Tags Directory</span> <span class="go">----------------------------------------------------------------------</span> <span class="go">4bba301e 2017-02-21 10:49:18 mopped /home/user/work</span> <span class="go">remove 1 snapshots:</span> <span class="go">ID Date Host Tags Directory</span> <span class="go">----------------------------------------------------------------------</span> <span class="go">8c02b94b 2017-02-21 10:48:33 mopped /home/user/work</span> <span class="go">1 snapshots have been removed, running prune</span> <span class="go">loading all snapshots...</span> <span class="go">loading indexes...</span> <span class="go">finding data that is still in use for 1 snapshots</span> <span class="gp">[0:00] 100.00% </span><span class="m">1</span> / <span class="m">1</span> snapshots <span class="go">searching used packs...</span> <span class="go">collecting packs for deletion and repacking</span> <span class="gp">[0:00] 100.00% </span><span class="m">5</span> / <span class="m">5</span> packs processed <span class="go">to repack: 69 blobs / 1.078 MiB</span> <span class="go">this removes 67 blobs / 1.047 MiB</span> <span class="go">to delete: 7 blobs / 25.726 KiB</span> <span class="go">total prune: 74 blobs / 1.072 MiB</span> <span class="go">remaining: 16 blobs / 38.003 KiB</span> <span class="go">unused size after prune: 0 B (0.00% of remaining size)</span> <span class="go">repacking packs</span> <span class="gp">[0:00] 100.00% </span><span class="m">2</span> / <span class="m">2</span> packs repacked <span class="go">rebuilding index</span> <span class="gp">[0:00] 100.00% </span><span class="m">3</span> / <span class="m">3</span> packs processed <span class="go">deleting obsolete index files</span> <span class="gp">[0:00] 100.00% </span><span class="m">3</span> / <span class="m">3</span> files deleted <span class="go">removing 3 old packs</span> <span class="gp">[0:00] 100.00% </span><span class="m">3</span> / <span class="m">3</span> files deleted <span class="go">done</span> </pre></div> </div> </section> <section id="removing-snapshots-according-to-a-policy"> <h2>Removing snapshots according to a policy<a class="headerlink" href="#removing-snapshots-according-to-a-policy" title="Permalink to this headline">¶</a></h2> <p>Removing snapshots manually is tedious and error-prone, therefore restic allows specifying which snapshots should be removed automatically according to a policy. You can specify how many hourly, daily, weekly, monthly and yearly snapshots to keep, any other snapshots are removed. The most important command-line parameter here is <code class="docutils literal notranslate"><span class="pre">--dry-run</span></code> which instructs restic to not remove anything but print which snapshots would be removed.</p> <p>When <code class="docutils literal notranslate"><span class="pre">forget</span></code> is run with a policy, restic loads the list of all snapshots, then groups these by host name and list of directories. The grouping options can be set with <code class="docutils literal notranslate"><span class="pre">--group-by</span></code>, to only group snapshots by paths and tags use <code class="docutils literal notranslate"><span class="pre">--group-by</span> <span class="pre">paths,tags</span></code>. The policy is then applied to each group of snapshots separately. This is a safety feature.</p> <p>The <code class="docutils literal notranslate"><span class="pre">forget</span></code> command accepts the following parameters:</p> <ul class="simple"> <li><p><code class="docutils literal notranslate"><span class="pre">--keep-last</span> <span class="pre">n</span></code> never delete the <code class="docutils literal notranslate"><span class="pre">n</span></code> last (most recent) snapshots</p></li> <li><p><code class="docutils literal notranslate"><span class="pre">--keep-hourly</span> <span class="pre">n</span></code> for the last <code class="docutils literal notranslate"><span class="pre">n</span></code> hours in which a snapshot was made, keep only the last snapshot for each hour.</p></li> <li><p><code class="docutils literal notranslate"><span class="pre">--keep-daily</span> <span class="pre">n</span></code> for the last <code class="docutils literal notranslate"><span class="pre">n</span></code> days which have one or more snapshots, only keep the last one for that day.</p></li> <li><p><code class="docutils literal notranslate"><span class="pre">--keep-weekly</span> <span class="pre">n</span></code> for the last <code class="docutils literal notranslate"><span class="pre">n</span></code> weeks which have one or more snapshots, only keep the last one for that week.</p></li> <li><p><code class="docutils literal notranslate"><span class="pre">--keep-monthly</span> <span class="pre">n</span></code> for the last <code class="docutils literal notranslate"><span class="pre">n</span></code> months which have one or more snapshots, only keep the last one for that month.</p></li> <li><p><code class="docutils literal notranslate"><span class="pre">--keep-yearly</span> <span class="pre">n</span></code> for the last <code class="docutils literal notranslate"><span class="pre">n</span></code> years which have one or more snapshots, only keep the last one for that year.</p></li> <li><p><code class="docutils literal notranslate"><span class="pre">--keep-tag</span></code> keep all snapshots which have all tags specified by this option (can be specified multiple times).</p></li> <li><p><code class="docutils literal notranslate"><span class="pre">--keep-within</span> <span class="pre">duration</span></code> keep all snapshots which have been made within the duration of the latest snapshot. <code class="docutils literal notranslate"><span class="pre">duration</span></code> needs to be a number of years, months, days, and hours, e.g. <code class="docutils literal notranslate"><span class="pre">2y5m7d3h</span></code> will keep all snapshots made in the two years, five months, seven days, and three hours before the latest snapshot.</p></li> <li><p><code class="docutils literal notranslate"><span class="pre">--keep-within-hourly</span> <span class="pre">duration</span></code> keep all hourly snapshots made within specified duration of the latest snapshot. The duration is specified in the same way as for <code class="docutils literal notranslate"><span class="pre">--keep-within</span></code> and the method for determining hourly snapshots is the same as for <code class="docutils literal notranslate"><span class="pre">--keep-hourly</span></code>.</p></li> <li><p><code class="docutils literal notranslate"><span class="pre">--keep-within-daily</span> <span class="pre">duration</span></code> keep all daily snapshots made within specified duration of the latest snapshot.</p></li> <li><p><code class="docutils literal notranslate"><span class="pre">--keep-within-weekly</span> <span class="pre">duration</span></code> keep all weekly snapshots made within specified duration of the latest snapshot.</p></li> <li><p><code class="docutils literal notranslate"><span class="pre">--keep-within-monthly</span> <span class="pre">duration</span></code> keep all monthly snapshots made within specified duration of the latest snapshot.</p></li> <li><p><code class="docutils literal notranslate"><span class="pre">--keep-within-yearly</span> <span class="pre">duration</span></code> keep all yearly snapshots made within specified duration of the latest snapshot.</p></li> </ul> <div class="admonition note"> <p class="admonition-title">Note</p> <p>All calendar related <code class="docutils literal notranslate"><span class="pre">--keep-*</span></code> options work on the natural time boundaries and not relative to when you run the <code class="docutils literal notranslate"><span class="pre">forget</span></code> command. Weeks are Monday 00:00 -> Sunday 23:59, days 00:00 to 23:59, hours :00 to :59, etc.</p> </div> <div class="admonition note"> <p class="admonition-title">Note</p> <p>Specifying <code class="docutils literal notranslate"><span class="pre">--keep-tag</span> <span class="pre">''</span></code> will match untagged snapshots only.</p> </div> <p>Multiple policies will be ORed together so as to be as inclusive as possible for keeping snapshots.</p> <p>Additionally, you can restrict removing snapshots to those which have a particular hostname with the <code class="docutils literal notranslate"><span class="pre">--host</span></code> parameter, or tags with the <code class="docutils literal notranslate"><span class="pre">--tag</span></code> option. When multiple tags are specified, only the snapshots which have all the tags are considered. For example, the following command removes all but the latest snapshot of all snapshots that have the tag <code class="docutils literal notranslate"><span class="pre">foo</span></code>:</p> <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>restic forget --tag foo --keep-last <span class="m">1</span> </pre></div> </div> <p>This command removes all but the last snapshot of all snapshots that have either the <code class="docutils literal notranslate"><span class="pre">foo</span></code> or <code class="docutils literal notranslate"><span class="pre">bar</span></code> tag set:</p> <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>restic forget --tag foo --tag bar --keep-last <span class="m">1</span> </pre></div> </div> <p>To only keep the last snapshot of all snapshots with both the tag <code class="docutils literal notranslate"><span class="pre">foo</span></code> and <code class="docutils literal notranslate"><span class="pre">bar</span></code> set use:</p> <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>restic forget --tag foo,bar --keep-last <span class="m">1</span> </pre></div> </div> <p>To ensure only untagged snapshots are considered, specify the empty string ‘’ as the tag.</p> <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>restic forget --tag <span class="s1">''</span> --keep-last <span class="m">1</span> </pre></div> </div> <p>All the <code class="docutils literal notranslate"><span class="pre">--keep-*</span></code> options above only count hours/days/weeks/months/years which have a snapshot, so those without a snapshot are ignored.</p> <p>For safety reasons, restic refuses to act on an “empty” policy. For example, if one were to specify <code class="docutils literal notranslate"><span class="pre">--keep-last</span> <span class="pre">0</span></code> to forget <em>all</em> snapshots in the repository, restic will respond that no snapshots will be removed. To delete all snapshots, use <code class="docutils literal notranslate"><span class="pre">--keep-last</span> <span class="pre">1</span></code> and then finally remove the last snapshot ID manually (by passing the ID to <code class="docutils literal notranslate"><span class="pre">forget</span></code>).</p> <p>All snapshots are evaluated against all matching <code class="docutils literal notranslate"><span class="pre">--keep-*</span></code> counts. A single snapshot on 2017-09-30 (Sat) will count as a daily, weekly and monthly.</p> <p>Let’s explain this with an example: Suppose you have only made a backup on each Sunday for 12 weeks:</p> <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>restic snapshots <span class="go">repository f00c6e2a opened successfully, password is correct</span> <span class="go">ID Time Host Tags Paths</span> <span class="go">---------------------------------------------------------------</span> <span class="go">0a1f9759 2019-09-01 11:00:00 mopped /home/user/work</span> <span class="go">46cfe4d5 2019-09-08 11:00:00 mopped /home/user/work</span> <span class="go">f6b1f037 2019-09-15 11:00:00 mopped /home/user/work</span> <span class="go">eb430a5d 2019-09-22 11:00:00 mopped /home/user/work</span> <span class="go">8cf1cb9a 2019-09-29 11:00:00 mopped /home/user/work</span> <span class="go">5d33b116 2019-10-06 11:00:00 mopped /home/user/work</span> <span class="go">b9553125 2019-10-13 11:00:00 mopped /home/user/work</span> <span class="go">e1a7b58b 2019-10-20 11:00:00 mopped /home/user/work</span> <span class="go">8f8018c0 2019-10-27 11:00:00 mopped /home/user/work</span> <span class="go">59403279 2019-11-03 11:00:00 mopped /home/user/work</span> <span class="go">dfee9fb4 2019-11-10 11:00:00 mopped /home/user/work</span> <span class="go">e1ae2f40 2019-11-17 11:00:00 mopped /home/user/work</span> <span class="go">---------------------------------------------------------------</span> <span class="go">12 snapshots</span> </pre></div> </div> <p>Then <code class="docutils literal notranslate"><span class="pre">forget</span> <span class="pre">--keep-daily</span> <span class="pre">4</span></code> will keep the last four snapshots for the last four Sundays, but remove the rest:</p> <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>restic forget --keep-daily <span class="m">4</span> --dry-run <span class="go">repository f00c6e2a opened successfully, password is correct</span> <span class="go">Applying Policy: keep the last 4 daily snapshots</span> <span class="go">keep 4 snapshots:</span> <span class="go">ID Time Host Tags Reasons Paths</span> <span class="go">-------------------------------------------------------------------------------</span> <span class="go">8f8018c0 2019-10-27 11:00:00 mopped daily snapshot /home/user/work</span> <span class="go">59403279 2019-11-03 11:00:00 mopped daily snapshot /home/user/work</span> <span class="go">dfee9fb4 2019-11-10 11:00:00 mopped daily snapshot /home/user/work</span> <span class="go">e1ae2f40 2019-11-17 11:00:00 mopped daily snapshot /home/user/work</span> <span class="go">-------------------------------------------------------------------------------</span> <span class="go">4 snapshots</span> <span class="go">remove 8 snapshots:</span> <span class="go">ID Time Host Tags Paths</span> <span class="go">---------------------------------------------------------------</span> <span class="go">0a1f9759 2019-09-01 11:00:00 mopped /home/user/work</span> <span class="go">46cfe4d5 2019-09-08 11:00:00 mopped /home/user/work</span> <span class="go">f6b1f037 2019-09-15 11:00:00 mopped /home/user/work</span> <span class="go">eb430a5d 2019-09-22 11:00:00 mopped /home/user/work</span> <span class="go">8cf1cb9a 2019-09-29 11:00:00 mopped /home/user/work</span> <span class="go">5d33b116 2019-10-06 11:00:00 mopped /home/user/work</span> <span class="go">b9553125 2019-10-13 11:00:00 mopped /home/user/work</span> <span class="go">e1a7b58b 2019-10-20 11:00:00 mopped /home/user/work</span> <span class="go">---------------------------------------------------------------</span> <span class="go">8 snapshots</span> </pre></div> </div> <p>The result of the <code class="docutils literal notranslate"><span class="pre">forget</span> <span class="pre">--keep-daily</span></code> operation does not depend on when it is run, it will only count the days for which a snapshot exists. This is a safety feature: it prevents restic from removing snapshots when no new ones are created. Otherwise, running <code class="docutils literal notranslate"><span class="pre">forget</span> <span class="pre">--keep-daily</span> <span class="pre">4</span></code> on a Friday (without any snapshot Monday to Thursday) would remove all snapshots!</p> <p>Another example: Suppose you make daily backups for 100 years. Then <code class="docutils literal notranslate"><span class="pre">forget</span> <span class="pre">--keep-daily</span> <span class="pre">7</span> <span class="pre">--keep-weekly</span> <span class="pre">5</span> <span class="pre">--keep-monthly</span> <span class="pre">12</span> <span class="pre">--keep-yearly</span> <span class="pre">75</span></code> will keep the most recent 7 daily snapshots, then 4 (remember, 7 dailies already include a week!) last-day-of-the-weeks and 11 or 12 last-day-of-the-months (11 or 12 depends if the 5 weeklies cross a month). And finally 75 last-day-of-the-year snapshots. All other snapshots are removed.</p> <p>You might want to maintain the same policy as for the example above, but have irregular backups. For example, the 7 snapshots specified with <code class="docutils literal notranslate"><span class="pre">--keep-daily</span> <span class="pre">7</span></code> might be spread over a longer period. If what you want is to keep daily snapshots for a week, weekly for a month, monthly for a year and yearly for 75 years, you could specify: <code class="docutils literal notranslate"><span class="pre">forget</span> <span class="pre">--keep-daily-within</span> <span class="pre">7d</span> <span class="pre">--keep-weekly-within</span> <span class="pre">1m</span> <span class="pre">--keep-monthly-within</span> <span class="pre">1y</span> <span class="pre">--keep-yearly-within</span> <span class="pre">75y</span></code> (Note that <cite>1w</cite> is not a recognized duration, so you will have to specify <cite>7d</cite> instead)</p> </section> <section id="customize-pruning"> <h2>Customize pruning<a class="headerlink" href="#customize-pruning" title="Permalink to this headline">¶</a></h2> <p>To understand the custom options, we first explain how the pruning process works:</p> <ol class="arabic"> <li><p>All snapshots and directories within snapshots are scanned to determine which data is still in use.</p></li> <li><p>For all files in the repository, restic finds out if the file is fully used, partly used or completely unused.</p></li> <li><p>Completely unused files are marked for deletion. Fully used files are kept. A partially used file is either kept or marked for repacking depending on user options.</p> <p>Note that for repacking, restic must download the file from the repository storage and re-upload the needed data in the repository. This can be very time-consuming for remote repositories.</p> </li> <li><p>After deciding what to do, <code class="docutils literal notranslate"><span class="pre">prune</span></code> will actually perform the repack, modify the index according to the changes and delete the obsolete files.</p></li> </ol> <p>The <code class="docutils literal notranslate"><span class="pre">prune</span></code> command accepts the following options:</p> <ul> <li><p><code class="docutils literal notranslate"><span class="pre">--max-unused</span> <span class="pre">limit</span></code> allow unused data up to the specified limit within the repository. This allows restic to keep partly used files instead of repacking them.</p> <p>The limit can be specified in several ways:</p> <blockquote> <div><ul class="simple"> <li><p>As an absolute size (e.g. <code class="docutils literal notranslate"><span class="pre">200M</span></code>). If you want to minimize the space used by your repository, pass <code class="docutils literal notranslate"><span class="pre">0</span></code> to this option.</p></li> <li><p>As a size relative to the total repo size (e.g. <code class="docutils literal notranslate"><span class="pre">10%</span></code>). This means that after prune, at most <code class="docutils literal notranslate"><span class="pre">10%</span></code> of the total data stored in the repo may be unused data. If the repo after prune has as size of 500MB, then at most 50MB may be unused.</p></li> <li><p>If the string <code class="docutils literal notranslate"><span class="pre">unlimited</span></code> is passed, there is no limit for partly unused files. This means that as long as some data is still used within a file stored in the repo, restic will just leave it there. Use this if you want to minimize the time and bandwidth used by the <code class="docutils literal notranslate"><span class="pre">prune</span></code> operation. Note that metadata will still be repacked.</p></li> </ul> </div></blockquote> <p>Restic tries to repack as little data as possible while still ensuring this limit for unused data. The default value is 5%.</p> </li> <li><p><code class="docutils literal notranslate"><span class="pre">--max-repack-size</span> <span class="pre">size</span></code> if set limits the total size of files to repack. As <code class="docutils literal notranslate"><span class="pre">prune</span></code> first stores all repacked files and deletes the obsolete files at the end, this option might be handy if you expect many files to be repacked and fear to run low on storage.</p></li> <li><p><code class="docutils literal notranslate"><span class="pre">--repack-cacheable-only</span></code> if set to true only files which contain metadata and would be stored in the cache are repacked. Other pack files are not repacked if this option is set. This allows a very fast repacking using only cached data. It can, however, imply that the unused data in your repository exceeds the value given by <code class="docutils literal notranslate"><span class="pre">--max-unused</span></code>. The default value is false.</p></li> <li><p><code class="docutils literal notranslate"><span class="pre">--dry-run</span></code> only show what <code class="docutils literal notranslate"><span class="pre">prune</span></code> would do.</p></li> <li><p><code class="docutils literal notranslate"><span class="pre">--verbose</span></code> increased verbosity shows additional statistics for <code class="docutils literal notranslate"><span class="pre">prune</span></code>.</p></li> </ul> </section> </section> </div> </div> <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> <a href="050_restore.html" class="btn btn-neutral float-left" title="Restoring from backup" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> <a href="070_encryption.html" class="btn btn-neutral float-right" title="Encryption" 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>