Inside this guide
To back up your Termux home folder, archive your projects and configuration files, copy it off the phone, and test it before deleting anything. When you restore, unpack the archive into a new folder first. That lets you inspect your files before you merge them into a fresh Termux setup.
Use these steps from a regular Termux shell on Android. You'll need GNU tar, enough free space for the archive, and a trusted place outside the phone to keep a copy. If GNU tar is missing from your Termux session, install it through Termux's package manager.
pkg install tarWhat this backup includes
The home folder contains your projects, scripts and dotfiles, such as shell settings. Termux keeps the programs you install with its package manager in a separate location called the prefix. This guide archives the home folder only. Reinstall the tools you need on the new phone instead of copying the old package directory wholesale.
If you have Termux storage shortcuts, the archive skips the top-level storage folder. Back up any Android downloads, photos, or files saved through those links separately. If you saved real files directly inside the storage folder, those are excluded too.
Create and inspect the archive
Stop any active project jobs that are writing to your home folder. Then run the command below. It creates a new backup directory and archives the contents of your home folder, including hidden files.
mkdir ~/termux-home-backup && tar --exclude='./termux-home-backup' --exclude='./termux-restore-check' --exclude='./storage' -czf ~/termux-home-backup/home.tar.gz -C ~ .The command skips its own output directory and the restore test directory used below. If the directory already exists, mkdir fails and tar does not run. Preserve the previous backup before reusing the name. If tar reports an error, treat the resulting archive as incomplete.
List the saved files and check for a few important projects and dotfiles you expect to see.
tar -tzf ~/termux-home-backup/home.tar.gzSave a package inventory alongside the archive. Use it to identify the tools you need to reinstall.
pkg list-installed > ~/termux-home-backup/packages.txtSave a copy outside the phone
Keep both files somewhere you can reach if the phone is lost or reset. In an Android file manager that supports the system document picker, look for the Termux location to open its home folder. Copy the backup folder out using a transfer method you trust. If your setup already exposes Android shared storage, you can use it as a temporary transfer location for a backup that contains no secrets or has been encrypted. A backup stored only inside Termux can disappear when you uninstall the app or clear its data.
Test a restore in a separate folder
On the destination phone, install Termux and GNU tar. Then use the document picker or your trusted transfer method to place the backup folder in Termux home. You can also test the original archive on your current phone before making changes. Only unpack an archive you created or trust.
mkdir ~/termux-restore-check && tar -xzf ~/termux-home-backup/home.tar.gz -C ~/termux-restore-checkThis creates a new directory. If it already exists, use a fresh directory name in both places in the command. Open a few restored files, including a hidden configuration file if you backed one up. Reinstall needed packages using your inventory as a reference, then copy the projects and settings you need into place. Review old absolute paths and startup files before reusing them. Keep the original backup until the restored projects work.
Cover illustration generated with AI.
Prepared with AI-assisted research and writing using the sources below.
Sources
https://github.com/termux/termux-packages/wiki/Termux-file-system-layout
https://github.com/termux/termux-tools/blob/master/doc/termux.1.md.in



