Is it possible to restore a distrobox that I rm’ed?

TL;DR can I restore a distrobox that I rm’ed? If so, where are the files located?

I reinstalled a while back, and my /etc/distrobox/distrobox.ini is now the default, whereas I had customized a couple of distroboxes, installed software, etc.
Yesterday, I didn’t realize all of this, and, having some trouble with an app I installed in my Ubuntu distrobox, I just rm’ed it. When I recreated it, of course it was back to the bare minimum, and the app wouldn’t run. I’m sure I could reinstall everything, set up shared volumes, etc.
I’m now using my fedora distrobox with the app, but that is where I realized it was out of sync with /etc/distrbox/distrobox.ini.
I realize these containers are composed of layers, and this might be asking a lot.

Thanks for any suggestions!

Hi John!

I’m not sure on this but figured this would make a good test. I’ve been learning our ai tool dosu.dev and I’ve been training it on all of our docs, source code, etc. I included upstream documentation as well, let’s see how it did.


You can restore a removed Distrobox container if you have previously created a backup or snapshot of it. Distrobox allows you to save, export, and restore containers using Podman or Docker. Here’s how you can do it:

  1. Save the Container:

    • With Podman:
      podman container commit -p distrobox_name image_name_you_choose
      podman save image_name_you_choose:latest | bzip2 > image_name_you_choose.tar.bz
      
    • With Docker:
      docker container commit -p distrobox_name image_name_you_choose
      docker save image_name_you_choose:latest | gzip > image_name_you_choose.tar.gz
      
  2. Restore the Container:

    • Load the image:
      • With Podman:
        podman load < image_name_you_choose.tar.bz2
        
      • With Docker:
        docker load < image_name_you_choose.tar.gz
        
  3. Create a New Container:

    distrobox create --image image_name_you_choose:latest --name distrobox_name
    distrobox enter --name distrobox_name
    

Unfortunately, if you haven’t created a backup before removing the container, it might not be possible to restore it to its previous state. In the future, consider regularly backing up your containers to prevent data loss [1].

Hi Jorge!

Thanks. I’ll give that a try. Should be helpful going forward.

Pretty sure it did a way better job than I would have!