<spanid="rbackup-struct-hierarchy-module"></span><h2>rbackup.struct.hierarchy module<aclass="headerlink"href="#module-rbackup.struct.hierarchy"title="Permalink to this headline">¶</a></h2>
<emclass="property">class </em><codeclass="descclassname">rbackup.struct.hierarchy.</code><codeclass="descname">Hierarchy</code><spanclass="sig-paren">(</span><em>dest</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#rbackup.struct.hierarchy.Hierarchy"title="Permalink to this definition">¶</a></dt>
<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 <codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">shutil.mkdir()</span></code> or related method to create
the directory structure it emulates.</p>
<p>Implementation Details</p>
<ulclass="simple">
<li><p>For consistency, <codeclass="docutils literal notranslate"><spanclass="pre">Hierarchy</span></code> objects always store and return absolute paths</p></li>
<li><p>Data for all <codeclass="docutils literal notranslate"><spanclass="pre">Hierarchy</span></code> objects and subclassed objects use JSON for serialization</p></li>
<codeclass="descname">gen_metadata</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="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>
<codeclass="descname">metadata_path</code><aclass="headerlink"href="#rbackup.struct.hierarchy.Hierarchy.metadata_path"title="Permalink to this definition">¶</a></dt>
<dd><dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>the path of this hierarchy’s metadata file.</p>
</dd>
<dtclass="field-even">Return type</dt>
<ddclass="field-even"><p>path-like object</p>
</dd>
</dl>
</dd></dl>
<dlclass="attribute">
<dtid="rbackup.struct.hierarchy.Hierarchy.name">
<codeclass="descname">name</code><aclass="headerlink"href="#rbackup.struct.hierarchy.Hierarchy.name"title="Permalink to this definition">¶</a></dt>
<dd><dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>the name of this hierarchy.</p>
</dd>
<dtclass="field-even">Return type</dt>
<ddclass="field-even"><p>str</p>
</dd>
</dl>
</dd></dl>
<dlclass="attribute">
<dtid="rbackup.struct.hierarchy.Hierarchy.path">
<codeclass="descname">path</code><aclass="headerlink"href="#rbackup.struct.hierarchy.Hierarchy.path"title="Permalink to this definition">¶</a></dt>
<dd><dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>the base directory of this hierarchy</p>
<codeclass="descname">read_metadata</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#rbackup.struct.hierarchy.Hierarchy.read_metadata"title="Permalink to this definition">¶</a></dt>
<dd><p>Read this repository’s metadata from its file and
then return it.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>type that the data is serialized as</p>
<codeclass="descname">write_metadata</code><spanclass="sig-paren">(</span><em>attr</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#rbackup.struct.hierarchy.Hierarchy.write_metadata"title="Permalink to this definition">¶</a></dt>
<dd><p>Write this repository’s metadata to its metadata file.</p>
<divclass="admonition note">
<pclass="admonition-title">Note</p>
<p>This write operation is atomic to the caller.</p>
</div>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>attr</strong> (<em>any type</em>) – class data to write to file</p>
<spanid="rbackup-struct-repository-module"></span><h2>rbackup.struct.repository module<aclass="headerlink"href="#module-rbackup.struct.repository"title="Permalink to this headline">¶</a></h2>
<spanclass="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>
<ulclass="simple">
<li><dlclass="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>
<dlclass="class">
<dtid="rbackup.struct.repository.Repository">
<emclass="property">class </em><codeclass="descclassname">rbackup.struct.repository.</code><codeclass="descname">Repository</code><spanclass="sig-paren">(</span><em>dest</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#rbackup.struct.repository.Repository"title="Permalink to this definition">¶</a></dt>
<codeclass="descname">cleanup</code><spanclass="sig-paren">(</span><em>*</em>, <em>remove_snapshots=False</em>, <em>remove_repo_dir=False</em><spanclass="sig-paren">)</span><aclass="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>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="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>
<codeclass="descname">create_snapshot</code><spanclass="sig-paren">(</span><em>name=None</em><spanclass="sig-paren">)</span><aclass="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 snapshot’s 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>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>name</strong> (<em>str</em>) – the name of the snapshot</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>Snapshot object</p>
</dd>
<dtclass="field-odd">Raises</dt>
<ddclass="field-odd"><p><strong>ValueError</strong>– if name is an invalid value</p>
<codeclass="descname">empty</code><aclass="headerlink"href="#rbackup.struct.repository.Repository.empty"title="Permalink to this definition">¶</a></dt>
<dd><dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>True if there are no Snapshots in this Repository,
<codeclass="descname">gen_metadata</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="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>
<emclass="property">static </em><codeclass="descname">is_valid_snapshot_name</code><spanclass="sig-paren">(</span><em>name</em><spanclass="sig-paren">)</span><aclass="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>
<ulclass="simple">
<li><p>Contain slashes</p></li>
<li><p>Are empty values</p></li>
</ul>
<p>Valid names:</p>
<ulclass="simple">
<li><p>Match the regex r’[w]+[^/]*’</p></li>
</ul>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>name</strong> (<em>str</em>) – name to validate</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>true if this name is deemed valid, otherwise False</p>
<codeclass="descname">snapshot_dir</code><aclass="headerlink"href="#rbackup.struct.repository.Repository.snapshot_dir"title="Permalink to this definition">¶</a></dt>
<dd><dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>the directory in this Repository in which snapshots
<codeclass="descname">snapshots</code><aclass="headerlink"href="#rbackup.struct.repository.Repository.snapshots"title="Permalink to this definition">¶</a></dt>
<dd><dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>all snapshots stored in this repository</p>
</dd>
<dtclass="field-even">Return type</dt>
<ddclass="field-even"><p>list of Snapshot objects</p>
<codeclass="descname">symlink_snapshot</code><spanclass="sig-paren">(</span><em>snapshot</em><spanclass="sig-paren">)</span><aclass="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>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>snapshot</strong> (<em>Snapshot object</em>) – the snapshot to create the symlink to</p>
<spanid="rbackup-struct-snapshot-module"></span><h2>rbackup.struct.snapshot module<aclass="headerlink"href="#module-rbackup.struct.snapshot"title="Permalink to this headline">¶</a></h2>
<emclass="property">class </em><codeclass="descclassname">rbackup.struct.snapshot.</code><codeclass="descname">Snapshot</code><spanclass="sig-paren">(</span><em>path</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#rbackup.struct.snapshot.Snapshot"title="Permalink to this definition">¶</a></dt>
<codeclass="descname">gen_metadata</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="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>
<dlclass="attribute">
<dtid="rbackup.struct.snapshot.Snapshot.pkg_dir">
<codeclass="descname">pkg_dir</code><aclass="headerlink"href="#rbackup.struct.snapshot.Snapshot.pkg_dir"title="Permalink to this definition">¶</a></dt>
<dd><dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>the package manager backup directory of this snapshot.</p>
</dd>
<dtclass="field-even">Return type</dt>
<ddclass="field-even"><p>path-like object</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
</div>
<divclass="section"id="module-rbackup.struct">
<spanid="module-contents"></span><h2>Module contents<aclass="headerlink"href="#module-rbackup.struct"title="Permalink to this headline">¶</a></h2>