How to Back Up and Restore Flatpak Apps
In this article
You can back up Flatpak apps by copying two directories: ~/.var/app (per‑app user data) and ~/.local/share/flatpak (installed app files and metadata). To restore, copy them back to the same paths on the new system, then run flatpak repair and flatpak update. This preserves your apps, their settings, and user data without re‑downloading everything from the internet.
What You'll Need
- A Linux system with Flatpak installed (most distributions include it or offer it via the package manager).
- A terminal application (e.g., GNOME Terminal, Konsole, xterm).
- An external drive, network share, or cloud folder with enough free space to hold the backup (size varies; a typical set of apps and data can be several gigabytes).
- Basic familiarity with copying files and using the command line.
Step-by-Step
- Close all Flatpak apps. Quit any running Flatpak application to avoid copying files that are in use. You can check for running Flatpaks with
flatpak psin a terminal; if any are listed, close them normally. - Create a backup folder. Choose a location on your external drive or home directory, for example
~/flatpak-backup. Create it withmkdir -p ~/flatpak-backup. - Copy the user data directory. Run
cp -a ~/.var/app ~/flatpak-backup/. The-aflag preserves permissions and timestamps, which helps when restoring. - Copy the Flatpak installation directory. Run
cp -a ~/.local/share/flatpak ~/flatpak-backup/. This contains the app files, runtimes, and metadata for user‑installed Flatpaks. - Optional: back up system‑wide installations. If you have Flatpaks installed system‑wide (e.g., via
sudo flatpak install), also copy/var/lib/flatpakwithsudo cp -a /var/lib/flatpak ~/flatpak-backup/. You will need root privileges. - Verify the backup. List the contents of your backup folder to ensure the directories are present:
ls ~/flatpak-backup. You should seeappandflatpak(and possiblyflatpak-systemif you copied the system directory). - Restore on the target system. Install Flatpak if it is not already present. Then close all Flatpak apps and copy the backup directories back to their original locations:
cp -a ~/flatpak-backup/app ~/.var/andcp -a ~/flatpak-backup/flatpak ~/.local/share/. If you backed up the system directory, restore it withsudo cp -a ~/flatpak-backup/flatpak-system /var/lib/flatpak(adjust the path as needed). - Repair and update. Run
flatpak repairto fix any inconsistencies, thenflatpak updateto fetch the latest versions. This ensures the restored apps work correctly with the current runtime. - Test your apps. Launch a few Flatpak applications to confirm they start and retain their settings and data.
Common Mistakes
- Copying while apps are running. This can lead to corrupted or incomplete data. Always close Flatpak apps first.
- Forgetting the
-aflag. Without it, permissions and ownership may be lost, causing apps to fail on restore. - Mixing user and system installations. User‑installed Flatpaks live in
~/.local/share/flatpak, while system‑wide ones are in/var/lib/flatpak. Back up both if you use both. - Not running
flatpak repairafter restore. Skipping this step can leave the installation in an inconsistent state. - Assuming all data is in
~/.var/app. Some apps store data elsewhere (e.g., in the home directory directly). Check app documentation if you need a complete backup.
Tips
- Use
rsync -ainstead ofcp -afor large backups; it can resume interrupted transfers and is more efficient. - Compress the backup folder with
tar -czf flatpak-backup.tar.gz ~/flatpak-backupto save space and simplify transfer. - Keep multiple backup versions (e.g., dated folders) in case a recent backup is corrupted.
- Test the restore process on a virtual machine or spare user account before relying on it for critical data.
- Regularly update your backup after installing new apps or making significant configuration changes.
Troubleshooting
- Apps fail to launch after restore. Run
flatpak repairand thenflatpak update. If the issue persists, check that the runtime versions match; you may need to reinstall the app. - Permission errors. Ensure you copied with
-aand that your user owns the restored files. Usechown -R $USER:$USER ~/.var/appandchown -R $USER:$USER ~/.local/share/flatpakif needed. - Missing apps. Verify that you backed up both
~/.var/appand~/.local/share/flatpak. If you only backed up one, some apps may not appear. - Disk space issues. Restoring large backups may require more free space than the backup size. Check with
df -hbefore restoring. - Flatpak command not found. Install Flatpak via your distribution's package manager (e.g.,
sudo apt install flatpakon Debian/Ubuntu,sudo dnf install flatpakon Fedora).
Frequently Asked Questions
Can I back up only the app data and not the app itself?
Yes. Copying ~/.var/app preserves user data and settings. However, you will need to reinstall the apps themselves via flatpak install on the new system.
Do I need to back up system‑wide Flatpaks separately?
Yes, if you have apps installed system‑wide (in /var/lib/flatpak), you must back up that directory separately with root privileges.
Will restoring work across different Linux distributions?
Generally yes, as Flatpak is distribution‑independent. However, ensure the target system has a compatible Flatpak version and the necessary runtimes.
How do I find where a specific app stores its data?
Most Flatpak apps store data in ~/.var/app/. You can list installed app IDs with flatpak list --app --columns=application.
Is it safe to copy the Flatpak directory while the system is running?
It is safe if no Flatpak apps are running, but for system‑wide installations, avoid copying while package updates are in progress.
Can I use a graphical file manager instead of the terminal?
Yes, you can copy the folders using a file manager, but ensure you enable “show hidden files” and preserve permissions if possible. The terminal method is more reliable for permissions.