{"id":3109,"date":"2025-11-20T21:43:20","date_gmt":"2025-11-21T04:43:20","guid":{"rendered":"https:\/\/catbradley.io\/?p=3109"},"modified":"2025-11-20T21:43:20","modified_gmt":"2025-11-21T04:43:20","slug":"move-between-the-distros-back-up-and-restore-your-snap-packages","status":"publish","type":"post","link":"https:\/\/catbradley.io\/?p=3109","title":{"rendered":"Move Between the Distros: Back Up and Restore Your Snap Packages"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/itsfoss.com\/content\/images\/2025\/11\/backup-snap-packages.png\" alt=\"Move Between the Distros: Back Up and Restore Your Snap Packages\" \/><\/p>\n<p>The <a href=\"https:\/\/itsfoss.com\/use-snap-packages-ubuntu-16-04\/\" rel=\"noreferrer\">Snap packaging system<\/a> makes it easy to install and update software on any Linux distribution that supports them. However,  if you\u2019ve ever had to reinstall your system, you\u2019ve probably been burned by the fact that Snap, like most other packaging systems, doesn\u2019t provide any built-in means for exporting your apps or moving them to a new machine.<\/p>\n<p>Thankfully, there&#8217;s good news: You can still. With just a few commands and a bit of organisation, you can export and restore your Snap applications on any other system where it&#8217;s supported.<\/p>\n<h2>\ud83d\udea7 Some things to keep in mind<\/h2>\n<p>Before you dive in, there are some key things to understand about the Snap packaging system and how it works. Snap doesn\u2019t yet have a built-in \u201cexport\/import\u201d tool like <a href=\"https:\/\/flatpak.org\/?ref=itsfoss.com\">Flatpak<\/a>. Neither packaging format allows you to repackage any packages you&#8217;ve already installed.<\/p>\n<p>Furthermore, with the Snap system, <strong>reinstalling restores the <em>latest<\/em> version of the package, not necessarily the exact revisions you previously had<\/strong>. Since many apps store extra data under <code>\/var\/snap\/<\/code>, you&#8217;ll likely need to restore this data as well, if you&#8217;re seeking to retain your settings when migrating. This article will show you how you can back up and restore this directory as well.<\/p>\n<h2>\u26a0\ufe0f What this tutorial cannot cover<\/h2>\n<p>Occasionally, Snap packages require hooks to enable certain features and integrations. Unfortunately, this is a more complicated process and must be done on a per-package basis. For this reason, we won&#8217;t cover how to do this for individual packages, as that process can differ for each package that requires it.<\/p>\n<p>Now, let&#8217;s dive in.<\/p>\n<h2>Step 1. Creating a list of installed snap packages<\/h2>\n<p>To get started, you&#8217;ll first need to save a list of every Snap package currently installed on your system:<\/p>\n<pre><code class=\"language-bash\">snap list --all | awk 'NR&gt;1 {print $1}' &gt; snap-list.txt\n<\/code><\/pre>\n<p>This will create a text file with the names of all your Snap packages. As with most other packaging systems, package names are all you need to refer to the packages you want to manage. However, if you&#8217;d keep a note of further details in this list, you can do so with the following command:<\/p>\n<pre><code class=\"language-bash\">snap list --all &gt; snap-list-detailed.txt\n<\/code><\/pre>\n<div class=\"kg-card kg-callout-card kg-callout-card-blue\">\n<div class=\"kg-callout-emoji\">\ud83d\uddd2\ufe0f<\/div>\n<div class=\"kg-callout-text\">Unlike with other packaging systems, you cannot restore particular revisions of an application with the Snap packaging system. This command is only useful for record keeping purpose.<\/div>\n<\/div>\n<h2>Step 2. Backing up your app data<\/h2>\n<p>Snap packages store their data and settings in your home folder within the <code>~\/snap<\/code> directory. Each app saves its data in a subdirectory of the same name. For example, Inkscape saves its data in <sub><code>\/snap\/inkscape<\/code> <\/sub>Firefox in<sub> <\/sub><code>\/snap\/firefox<\/code>, and so on.<\/p>\n<figure class=\"kg-card kg-image-card kg-card-hascaption\"><img decoding=\"async\" src=\"https:\/\/itsfoss.com\/content\/images\/2025\/11\/Screenshot-From-2025-11-17-14-50-34.png\" class=\"kg-image\" alt=\"Move Between the Distros: Back Up and Restore Your Snap Packages\" loading=\"lazy\" width=\"1268\" height=\"801\" \/><figcaption><span>Each Snap package has its own config and data directory<\/span><\/figcaption><\/figure>\n<p>You can back up individual apps if you&#8217;d like, but for the purposes of this tutorial, we&#8217;ll run through how to back up the entire directory.<\/p>\n<p><strong>To do this, you can run:<\/strong><\/p>\n<pre><code class=\"language-bash\">tar -czf snap-data-backup.tar.gz ~\/snap\/\n<\/code><\/pre>\n<p>Remember to copy this file along with <code>snap-list.txt<\/code> to the target system where you&#8217;ll be restoring your packages.<\/p>\n<div class=\"kg-card kg-callout-card kg-callout-card-blue\">\n<div class=\"kg-callout-emoji\">\ud83d\uddd2\ufe0f<\/div>\n<div class=\"kg-callout-text\">If you&#8217;re on a multi-user system, you&#8217;ll need to run this for each user on the system you&#8217;re transferring from.<\/div>\n<\/div>\n<h2>Step 3. Transferring to the target system<\/h2>\n<p>On the target system, you should first ensure Snap is installed and working.<\/p>\n<p>For the best results, it&#8217;s safest if the target system has the same or a newer version of Snap compared to the original. You can check the Snap version on both systems by running the following command:<\/p>\n<pre><code class=\"language-bash\">snap version\n<\/code><\/pre>\n<p>If you get output showing your snap version and other data, you\u2019re ready to go.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/itsfoss.com\/content\/images\/2025\/11\/Screenshot-From-2025-11-11-02-46-55.png\" class=\"kg-image\" alt=\"Move Between the Distros: Back Up and Restore Your Snap Packages\" loading=\"lazy\" width=\"746\" height=\"387\" \/><\/figure>\n<div class=\"kg-card kg-callout-card kg-callout-card-blue\">\n<div class=\"kg-callout-emoji\">\ud83d\uddd2\ufe0f<\/div>\n<div class=\"kg-callout-text\">If you&#8217;re running Ubuntu, Snap will be preinstalled. Most major distributions do not ship with Snap preinstalled, so you&#8217;ll need to install it before continuing.<\/div>\n<\/div>\n<h3>Installing your packages on the target system<\/h3>\n<p>In the same directory where you&#8217;ve copied the snap-list text file, run the following command to install the snap packages from your list:<\/p>\n<pre><code class=\"language-bash\">xargs -a snap-list.txt sudo snap install\n<\/code><\/pre>\n<p>Once this command is finished running, you&#8217;ll have all the same Snap apps and packages you&#8217;d have had on your previous system. Now, you can move on to restoring your app data.<\/p>\n<p>You can verify your apps successfully installed by running:<\/p>\n<pre><code class=\"language-bash\">snap list\n<\/code><\/pre>\n<h2>4. Restoring app data<\/h2>\n<p>Now that you&#8217;ve successfully restored your Snap apps and packages, you can restore your Snap package data. To do this, you can decompress the archive you created earlier in your home folder:<\/p>\n<pre><code class=\"language-bash\">tar -xzf snap-data-backup.tar.gz -C ~\/\n<\/code><\/pre>\n<p><strong>Remember, if you&#8217;ve done this for multiple users, this will need to be done in each user&#8217;s home folder individually.<\/strong><\/p>\n<h2>Optional bonus for advanced users: Automating your setup<\/h2>\n<p>If you regularly install or change your Snap packages, and you&#8217;d like to run this step more smoothly, you can automate it all with some simple scripting and <code>cron<\/code>.<\/p>\n<h3>Creating the script<\/h3>\n<p>For the script, you just to tie these commands together. Create a file such as <code>~\/bin\/snap-back.sh<\/code>, and give it executable permission:<\/p>\n<pre><code class=\"language-bash\"># Create the script:\ntouch ~\/bin\/snap-back.sh\n\n# Give it executable permission:\nchmod +x ~\/bin\/snap-back.sh<\/code><\/pre>\n<p>Now edit the script with the text editor of your choice, and add the following:<\/p>\n<pre><code class=\"language-bash\">#!\/bin\/bash\n# Backup Snap package list and user data\nsnap list --all | awk 'NR&gt;1 {print $1}' &gt; ~\/snap-list.txt\ntar -czf ~\/snap-data-backup.tar.gz ~\/snap\/\n\n# Optional: enable logging\necho \"Snap backup completed on $(date)\" &gt;&gt; ~\/snap-backup.log\n<\/code><\/pre>\n<p>If you don&#8217;t need to keep a log, you can remove the last line (and the comment above it).<\/p>\n<h3>Automating it all<\/h3>\n<p>If you&#8217;d like to have this back up run at regular intervals, you can schedule this process with <code>cron<\/code>:<\/p>\n<pre><code class=\"language-bash\"># Open your crontab\ncrontab -e<\/code><\/pre>\n<p>In the editor, add this line:<\/p>\n<pre><code>0 10 * * SUN ~\/bin\/snap-back.sh<\/code><\/pre>\n<p>This will set your Snap package backup to run automatically at the beginning of every week. You can choose any interval you&#8217;d prefer, of course.<\/p>\n<h2>Conclusion<\/h2>\n<p>Even though Snap doesn&#8217;t offer the same level of convenience as Flatpak, these steps still give you a dependable and scriptable way to preserve and transfer your setup. This is especially useful if you love to maintain the same setup across devices or like to do a fresh installation on upgrade. Remember, you can always keep your setup synced to a version control system or your personal cloud server.<\/p>","protected":false},"excerpt":{"rendered":"<p>The Snap packaging system makes it easy to install and update software on any Linux distribution that supports them. However, if you\u2019ve ever had to reinstall your system, you\u2019ve probably&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3109","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-rss"],"_links":{"self":[{"href":"https:\/\/catbradley.io\/index.php?rest_route=\/wp\/v2\/posts\/3109","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/catbradley.io\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/catbradley.io\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/catbradley.io\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/catbradley.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3109"}],"version-history":[{"count":0,"href":"https:\/\/catbradley.io\/index.php?rest_route=\/wp\/v2\/posts\/3109\/revisions"}],"wp:attachment":[{"href":"https:\/\/catbradley.io\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/catbradley.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/catbradley.io\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}