rbackup/doc/build/html/rbackup.struct.html
2019-04-14 22:19:34 -07:00

426 lines
21 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>rbackup.struct package &#8212; rbackup 0.3.1 documentation</title>
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/language_data.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="prev" title="rbackup.package_managers package" href="rbackup.package_managers.html" />
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="rbackup-struct-package">
<h1>rbackup.struct package<a class="headerlink" href="#rbackup-struct-package" title="Permalink to this headline"></a></h1>
<div class="section" id="submodules">
<h2>Submodules<a class="headerlink" href="#submodules" title="Permalink to this headline"></a></h2>
</div>
<div class="section" id="module-rbackup.struct.hierarchy">
<span id="rbackup-struct-hierarchy-module"></span><h2>rbackup.struct.hierarchy module<a class="headerlink" href="#module-rbackup.struct.hierarchy" title="Permalink to this headline"></a></h2>
<span class="target" id="module-rbackup.struct.hierarchy"></span><dl class="class">
<dt id="rbackup.struct.hierarchy.Hierarchy">
<em class="property">class </em><code class="descclassname">rbackup.struct.hierarchy.</code><code class="descname">Hierarchy</code><span class="sig-paren">(</span><em>dest</em><span class="sig-paren">)</span><a class="headerlink" href="#rbackup.struct.hierarchy.Hierarchy" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">os.PathLike</span></code></p>
<p>A general class for organizing a hierarchy of data.</p>
<p>Hierarchy objects are non-intrusive in that they do not affect
the filesystem upon creation. It is up to the caller
to call either <code class="xref py py-func docutils literal notranslate"><span class="pre">shutil.mkdir()</span></code> or related method to create
the directory structure it emulates.</p>
<p>Implementation Details</p>
<ul class="simple">
<li><p>For consistency, <code class="docutils literal notranslate"><span class="pre">Hierarchy</span></code> objects always store and return absolute paths</p></li>
<li><p>Data for all <code class="docutils literal notranslate"><span class="pre">Hierarchy</span></code> objects and subclassed objects use JSON for serialization</p></li>
</ul>
<dl class="method">
<dt id="rbackup.struct.hierarchy.Hierarchy.gen_metadata">
<code class="descname">gen_metadata</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#rbackup.struct.hierarchy.Hierarchy.gen_metadata" title="Permalink to this definition"></a></dt>
<dd><p>Generate metadata for this repository.</p>
<p>After this method is called, the data necessary for this hierarchy has been created.</p>
</dd></dl>
<dl class="attribute">
<dt id="rbackup.struct.hierarchy.Hierarchy.metadata_path">
<code class="descname">metadata_path</code><a class="headerlink" href="#rbackup.struct.hierarchy.Hierarchy.metadata_path" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>the path of this hierarchys metadata file.</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>path-like object</p>
</dd>
</dl>
</dd></dl>
<dl class="attribute">
<dt id="rbackup.struct.hierarchy.Hierarchy.name">
<code class="descname">name</code><a class="headerlink" href="#rbackup.struct.hierarchy.Hierarchy.name" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>the name of this hierarchy.</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>str</p>
</dd>
</dl>
</dd></dl>
<dl class="attribute">
<dt id="rbackup.struct.hierarchy.Hierarchy.path">
<code class="descname">path</code><a class="headerlink" href="#rbackup.struct.hierarchy.Hierarchy.path" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>the base directory of this hierarchy</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>path-like object</p>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="rbackup.struct.hierarchy.Hierarchy.read_metadata">
<code class="descname">read_metadata</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#rbackup.struct.hierarchy.Hierarchy.read_metadata" title="Permalink to this definition"></a></dt>
<dd><p>Read this repositorys metadata from its file and
then return it.</p>
<dl class="field-list simple">
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>type that the data is serialized as</p>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="rbackup.struct.hierarchy.Hierarchy.write_metadata">
<code class="descname">write_metadata</code><span class="sig-paren">(</span><em>attr</em><span class="sig-paren">)</span><a class="headerlink" href="#rbackup.struct.hierarchy.Hierarchy.write_metadata" title="Permalink to this definition"></a></dt>
<dd><p>Write this repositorys metadata to its metadata file.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>This write operation is atomic to the caller.</p>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>attr</strong> (<em>any type</em>) class data to write to file</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="module-rbackup.struct.repository">
<span id="rbackup-struct-repository-module"></span><h2>rbackup.struct.repository module<a class="headerlink" href="#module-rbackup.struct.repository" title="Permalink to this headline"></a></h2>
<span class="target" id="module-rbackup.struct.repository"></span><p>A repository is a directory that contains backup data
sequestered into snapshots and a symlink to the most
recently created snapshot.</p>
<p>Properties</p>
<ul class="simple">
<li><dl class="simple">
<dt>Each snapshot in a repository is unaware of one another,</dt><dd><p>this is the job of the repository to organize</p>
</dd>
</dl>
</li>
<li><p>Has a symlink pointing to the most recently created snapshot</p></li>
</ul>
<dl class="class">
<dt id="rbackup.struct.repository.Repository">
<em class="property">class </em><code class="descclassname">rbackup.struct.repository.</code><code class="descname">Repository</code><span class="sig-paren">(</span><em>dest</em><span class="sig-paren">)</span><a class="headerlink" href="#rbackup.struct.repository.Repository" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="#rbackup.struct.hierarchy.Hierarchy" title="rbackup.struct.hierarchy.Hierarchy"><code class="xref py py-class docutils literal notranslate"><span class="pre">rbackup.struct.hierarchy.Hierarchy</span></code></a></p>
<p>A class for interacting with a backup repository.</p>
<p>Snapshots can be accessed on a one-by-one basis through iteration.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">snapshot</span> <span class="ow">in</span> <span class="n">Repository</span><span class="p">(</span><span class="s1">&#39;backup&#39;</span><span class="p">):</span>
<span class="gp">... </span> <span class="o">...</span>
<span class="gp">...</span>
</pre></div>
</div>
<p>Snapshots on repositories can be retrieved by index using pythons
list slicing syntax.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">Repository</span><span class="p">(</span><span class="s1">&#39;backup&#39;</span><span class="p">)[:])</span>
<span class="go">[Snapshot(...), ...]</span>
</pre></div>
</div>
<p>Membership of a snapshot in a repository can be checked by name.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Repository</span><span class="p">(</span><span class="s1">&#39;backup&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">create_snapshot</span><span class="p">(</span><span class="s1">&#39;test&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="s1">&#39;test&#39;</span> <span class="ow">in</span> <span class="n">Repository</span><span class="p">(</span><span class="s1">&#39;backup&#39;</span><span class="p">)</span>
<span class="go">True</span>
</pre></div>
</div>
<p>Number of snapshots in a repository can be checked as well</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Repository</span><span class="p">(</span><span class="s1">&#39;backup&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">create_snapshot</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">len</span><span class="p">(</span><span class="n">Repository</span><span class="p">(</span><span class="s1">&#39;backup&#39;</span><span class="p">))</span>
<span class="go">1</span>
</pre></div>
</div>
<dl class="method">
<dt id="rbackup.struct.repository.Repository.cleanup">
<code class="descname">cleanup</code><span class="sig-paren">(</span><em>*</em>, <em>remove_snapshots=False</em>, <em>remove_repo_dir=False</em><span class="sig-paren">)</span><a class="headerlink" href="#rbackup.struct.repository.Repository.cleanup" title="Permalink to this definition"></a></dt>
<dd><p>Clean up any filesystem references to this repository.
By default, no snapshots are deleted.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>remove_snapshots</strong> (<em>bool</em>) delete the data directory of this repository</p></li>
<li><p><strong>remove_repo_dir</strong> (<em>bool</em>) remove the top-level directory of this repository</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="rbackup.struct.repository.Repository.create_snapshot">
<code class="descname">create_snapshot</code><span class="sig-paren">(</span><em>name=None</em><span class="sig-paren">)</span><a class="headerlink" href="#rbackup.struct.repository.Repository.create_snapshot" title="Permalink to this definition"></a></dt>
<dd><p>Create a new snapshot in this repository.</p>
<p>This operation is non-intrusive in that it will not
make any changes in the filesystem when called.</p>
<p>If name is not given, then the new snapshots name is the current
UTC date in ISO format.</p>
<p>If name is given, then it is the name for the new snapshot.</p>
<p>If name is given and it is the name of a snapshot already
on the repository, that snapshot is overwritten instead.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>name</strong> (<em>str</em>) the name of the snapshot</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Snapshot object</p>
</dd>
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><p><strong>ValueError</strong> if name is an invalid value</p>
</dd>
</dl>
</dd></dl>
<dl class="attribute">
<dt id="rbackup.struct.repository.Repository.empty">
<code class="descname">empty</code><a class="headerlink" href="#rbackup.struct.repository.Repository.empty" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>True if there are no Snapshots in this Repository,
False otherwise</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>bool</p>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="rbackup.struct.repository.Repository.gen_metadata">
<code class="descname">gen_metadata</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#rbackup.struct.repository.Repository.gen_metadata" title="Permalink to this definition"></a></dt>
<dd><p>Generate metadata for this repository.
After this method is called, the data necessary for this snapshot has been created.</p>
</dd></dl>
<dl class="staticmethod">
<dt id="rbackup.struct.repository.Repository.is_valid_snapshot_name">
<em class="property">static </em><code class="descname">is_valid_snapshot_name</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#rbackup.struct.repository.Repository.is_valid_snapshot_name" title="Permalink to this definition"></a></dt>
<dd><p>Check if the given name is a valid name.</p>
<p>Invalid Names:</p>
<ul class="simple">
<li><p>Contain slashes</p></li>
<li><p>Are empty values</p></li>
</ul>
<p>Valid names:</p>
<ul class="simple">
<li><p>Match the regex r[w]+[^/]*</p></li>
</ul>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>name</strong> (<em>str</em>) name to validate</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>true if this name is deemed valid, otherwise False</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>bool</p>
</dd>
</dl>
</dd></dl>
<dl class="attribute">
<dt id="rbackup.struct.repository.Repository.snapshot_dir">
<code class="descname">snapshot_dir</code><a class="headerlink" href="#rbackup.struct.repository.Repository.snapshot_dir" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>the directory in this Repository in which snapshots
are stored.</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>path-like object</p>
</dd>
</dl>
</dd></dl>
<dl class="attribute">
<dt id="rbackup.struct.repository.Repository.snapshots">
<code class="descname">snapshots</code><a class="headerlink" href="#rbackup.struct.repository.Repository.snapshots" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>all snapshots stored in this repository</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>list of Snapshot objects</p>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="rbackup.struct.repository.Repository.symlink_snapshot">
<code class="descname">symlink_snapshot</code><span class="sig-paren">(</span><em>snapshot</em><span class="sig-paren">)</span><a class="headerlink" href="#rbackup.struct.repository.Repository.symlink_snapshot" title="Permalink to this definition"></a></dt>
<dd><p>Create a symbolic link in the Repository directory to a snapshot.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>snapshot</strong> (<em>Snapshot object</em>) the snapshot to create the symlink to</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="module-rbackup.struct.snapshot">
<span id="rbackup-struct-snapshot-module"></span><h2>rbackup.struct.snapshot module<a class="headerlink" href="#module-rbackup.struct.snapshot" title="Permalink to this headline"></a></h2>
<span class="target" id="module-rbackup.struct.snapshot"></span><dl class="class">
<dt id="rbackup.struct.snapshot.Snapshot">
<em class="property">class </em><code class="descclassname">rbackup.struct.snapshot.</code><code class="descname">Snapshot</code><span class="sig-paren">(</span><em>path</em><span class="sig-paren">)</span><a class="headerlink" href="#rbackup.struct.snapshot.Snapshot" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="#rbackup.struct.hierarchy.Hierarchy" title="rbackup.struct.hierarchy.Hierarchy"><code class="xref py py-class docutils literal notranslate"><span class="pre">rbackup.struct.hierarchy.Hierarchy</span></code></a></p>
<p>Hierarchy for a single snapshot.</p>
<p>Data from each run of a backup script is intended to go here.</p>
<p>Snapshots are unaware of one another, it is up to a third-party caller
to orchestrate operations such as hardlinking between snapshots and
ordering snapshots.</p>
<dl class="method">
<dt id="rbackup.struct.snapshot.Snapshot.gen_metadata">
<code class="descname">gen_metadata</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#rbackup.struct.snapshot.Snapshot.gen_metadata" title="Permalink to this definition"></a></dt>
<dd><p>Generate metadata for this repository.</p>
<p>After this method is called, the data necessary for this hierarchy has been created.</p>
</dd></dl>
<dl class="attribute">
<dt id="rbackup.struct.snapshot.Snapshot.pkg_dir">
<code class="descname">pkg_dir</code><a class="headerlink" href="#rbackup.struct.snapshot.Snapshot.pkg_dir" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>the package manager backup directory of this snapshot.</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>path-like object</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="module-rbackup.struct">
<span id="module-contents"></span><h2>Module contents<a class="headerlink" href="#module-rbackup.struct" title="Permalink to this headline"></a></h2>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="index.html">rbackup</a></h1>
<h3>Navigation</h3>
<p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="rbackup.html">rbackup package</a><ul class="current">
<li class="toctree-l2 current"><a class="reference internal" href="rbackup.html#subpackages">Subpackages</a></li>
<li class="toctree-l2"><a class="reference internal" href="rbackup.html#submodules">Submodules</a></li>
<li class="toctree-l2"><a class="reference internal" href="rbackup.html#module-rbackup.config">rbackup.config module</a></li>
<li class="toctree-l2"><a class="reference internal" href="rbackup.html#module-rbackup.rsync">rbackup.rsync module</a></li>
<li class="toctree-l2"><a class="reference internal" href="rbackup.html#module-rbackup">Module contents</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="rbackup.package_managers.html">rbackup.package_managers package</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">rbackup.struct package</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#submodules">Submodules</a></li>
<li class="toctree-l2"><a class="reference internal" href="#module-rbackup.struct.hierarchy">rbackup.struct.hierarchy module</a></li>
<li class="toctree-l2"><a class="reference internal" href="#module-rbackup.struct.repository">rbackup.struct.repository module</a></li>
<li class="toctree-l2"><a class="reference internal" href="#module-rbackup.struct.snapshot">rbackup.struct.snapshot module</a></li>
<li class="toctree-l2"><a class="reference internal" href="#module-rbackup.struct">Module contents</a></li>
</ul>
</li>
</ul>
<div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="index.html">Documentation overview</a><ul>
<li><a href="rbackup.html">rbackup package</a><ul>
<li>Previous: <a href="rbackup.package_managers.html" title="previous chapter">rbackup.package_managers package</a></li>
</ul></li>
</ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2019, Eric Torres.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 2.0.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="_sources/rbackup.struct.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>