Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fedora - Backup and restore Toolboxes

#1
Backup and restore Toolboxes

<div></p>
<p><a href="https://fedoramagazine.org/a-quick-introduction-to-toolbox-on-fedora/">Toolboxes</a> started life often described as disposable containers – and that is still one of their major uses: install stuff, then try it out in the relative safety of a container, and lastly, cleanly dispose of it. Minimal risk, fuss and without pesky residual libraries and applications hanging around on the host long after you have finished.</p>
<p> <span id="more-31524"></span> </p>
<p>So — why would you backup a Toolbox? Sometimes, they have more permanent uses, contain complex and lengthy installs, or are being used for critical applications. For example, Toolboxes can be used as a development environment, containing hardware associated drivers and applications. Or they could be used for an application you want to run in a container for which there is no <a href="https://www.flatpak.org/">Flatpak</a>, or one that has requirements a Flatpak doesn’t satisfy. While they can be handy to use on <a href="https://getfedora.org/en/workstation/">Fedora Workstation</a>, toolbox containers are often essential for <a href="https://silverblue.fedoraproject.org/">Silverblue</a> users since they offer an easy solution to installing applications that can’t successfully be installed by rpm-ostree. Or for applications that may not have a Flatpak version readily available. In the above situations a busted Toolbox can be a major headache. But if a backup exists, you can quickly restore a Toolbox or move it to another workstation.</p>
<p>The backup process uses <a href="https://podman.io/">Podman</a> to create an image of an existing toolbox container, and save that image to an archive file. To restore the toolbox container, load the image from the archive file and then create a Toolbox from that image. The new toolbox container will be an identical copy of your backed up toolbox container.</p>
<p>It is important to note this process <strong>does not backup data</strong>, just what you have installed in the toolbox container. This includes packages installed from repositories or from a local rpm file using dnf. If you need to backup data, Podman’s <a href="http://docs.podman.io/en/latest/markdown/podman-commit.1.html">commit command</a> that will be used to capture an image of the toolbox container, has an option to include volumes attached to the container.</p>
<h3>Creating a backup</h3>
<p>To backup a toolbox container you will need it’s name and container ID which can be gotten by using <em>toolbox list</em>. For this example I am going to backup my golang development toolbox container, imaginatively named <em>go</em>.</p>
<pre class="wp-block-preformatted">$ <strong>toolbox list</strong> CONTAINER ID CONTAINER NAME CREATED STATUS IMAGE NAME
00ff783a102f go 5 weeks ago exited registry.fedoraproject.org/f32/fedora-toolbox:32
</pre>
<p>If the container’s status shows as running , you should stop it using <em>podman container stop container_name.</em> Although the commit command has a -p for pause option, make sure that the Toolbox is not running, which helps it initialize correctly when restored from backup.</p>
<pre class="wp-block-preformatted">$ <strong>podman container stop go</strong></pre>
<p>To create an image of the toolbox container use </p>
<div class="codecolorer-container text default" style="overflow:auto;border:1px solid #9F9F9F;width:435px">
<div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace">podman container commit -p container_ID backup-image-name</div>
</div>
<p> Depending on the complexity of the Toolbox, this can take a little while.</p>
<pre class="wp-block-preformatted"> <strong>$ podman container commit -p 00ff783a102f go-backup</strong></pre>
<p>Now to confirm the image has been created type…</p>
<pre class="wp-block-preformatted">$ <strong>toolbox list</strong></pre>
<p>You should get output similar to what is below…</p>
<pre class="wp-block-preformatted">IMAGE ID IMAGE NAME CREATED
cfcb13046db7 localhost/go-backup:latest About a minute ago CONTAINER ID CONTAINER NAME CREATED STATUS IMAGE NAME
00ff783a102f go 5 weeks ago exited registry.fedoraproject.org/f32/fedora-toolbox:32</pre>
<p>Now to save the backup image to a tar archive file using <em>podman save -o backup-filename.tar backup-image-name</em>.</p>
<pre class="wp-block-preformatted">$ <strong>podman save -o go.tar go-backup</strong></pre>
<p>Confirm the archive file, our toolbox container backup, was created.</p>
<pre class="wp-block-preformatted">$ <strong>ls</strong> go.tar </pre>
<p>Do some tidying up, remove the backup image and, if needed, remove the original Toolbox.</p>
<pre class="wp-block-preformatted">$<strong> podman rmi go-backup</strong> $<strong> toolbox rm go</strong></pre>
<h3>Restore a backup</h3>
<p>To create an image from the backup file that was made above, you do it with the command <em>podman load -i backup_filename</em>.</p>
<pre class="wp-block-preformatted">$ <strong>podman load -i go.tar</strong></pre>
<p>Then you can confirm the image was created with…</p>
<pre class="wp-block-preformatted">$ <strong>toolbox list</strong> IMAGE ID IMAGE NAME CREATED
cfcb13046db7 localhost/go-backup:latest 17 minutes ago
</pre>
<p>Now create a toolbox container from the restored image, with <em>toolbox create –</em>–<em>container container_name </em>––<em>image image_name</em>, specifying the full repository and version tag as the image name.</p>
<pre class="wp-block-preformatted">$ <strong>toolbox create --container go --image localhost/go-backup:latest</strong></pre>
<p>Confirm that the toolbox was created.</p>
<pre class="wp-block-preformatted">$ <strong>toolbox list</strong> IMAGE ID IMAGE NAME CREATED
cfcb13046db7 localhost/go-backup:latest 20 minutes ago CONTAINER ID CONTAINER NAME CREATED STATUS IMAGE NAME
34cef6b7e28d go 21 seconds ago configured localhost/go-backup:latest</pre>
<p>Finally, you can test that the restored Toolbox works…</p>
<pre class="wp-block-preformatted">$ <strong>toolbox enter --container go</strong></pre>
<p>If you can enter the newly created toolbox container, you will see the toolbox prompt and will have successfully backed up and restored your Pet toolbox container.</p>
</div>


https://www.sickgaming.net/blog/2020/08/...toolboxes/
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum software by © MyBB Theme © iAndrew 2016