With Snap and Apt both existing, how do I backup all my apps so that I can restore it on a new machine

I see a few solutions that do dpkg list or something along that line, Store it in a file and use that file to install the apps. My question is - will it also backup all the apps I installed from the snap store (Since I am having to install them using sudo snap install?)

Is there a better way I can back up all my apps, so I can get them installed on a new machine when I move to the machine? (Installed using APT OR Snap?)


Solution 1:

For snaps I think a Snapshot is the way to go.

For normal apt(.deb) software packages installed on your machine I think you could try these options:

  1. Check your apt archive directory(/var/cache/apt/archives) to see if this contains any .deb file. Those .deb are the software package from the applications you have in your system. If so, copy these .deb file to a USB stick from example, restore them on the new machine and once these files are on the new machine install them using sudo dpkg -i *.deb
  2. A second option if the previous step doesn't find anything would be to create the .deb for your current system, on console type:

    sudo apt-get install dpkg-repack
    mkdir repack
    cd repack
    dpkg-repack `dpkg --get-selections | grep install | cut -f1` 
    

The above commands will create the .deb files from your current installed system in the repack directory, from there you could copy these file to an USB stick, then restore them on the new machine, and again, perform an sudo dpkg -i *.deb on the new machine to install these deb applications in there

Solution 2:

I am the person who posted this question. Really helpful with the snap save. For the people who are more noob than me (if that is possible), what I've done is

  1. I did sudo snap save, this will generate a list of snaps - usually with a preceding ID (i.e. 12_app_name.zip, 12_another_app.zip) and this number will increment everytime you take a new snap save.

    You can do sudo cp /var/lib/snapd/snapshots/*.zip /path/to/backup/folder/

  2. Back it up to cloud or a disk.

  3. Copy it back to your new machine with sudo cp /path/to/backup/folder/*.zip /var/lib/snapd/snapshots/ and now you can snap restore ID (i.e. snap restore 12) and TADA!

The synaptic idea by @Organiz Marble was also pretty great. Please do that too.

I've done dpkg --get-selections > package_list. More here - How can I backup my programs/applications, so that after I reinstall a new one, I can still use the backup-ed ones?

(it also backups your PPAs). Thanks, everyone. I hope whoever finds this in the future sees this answer and takes the best of whatever they like :)

Solution 3:

For non-snaps:

You can use synaptic to save a list of all packages installed on your system through apt.

From the File menu select Save Markings As... and in the box that pops up, specify a storage location. Be sure to tick the Save full state, not only changes option in this box!

This saves a text file with all packages installed through apt. You can install them on the new system using synaptic by selecting from the File menu Read Markings...

Reference