Termux-Sync: Back Up and Restore Your Entire Termux Environment Across Android Devices (2026)

Termux-Sync: Back Up and Restore Your Entire Termux Environment Across Android Devices (2026)

Backup Termux in 1 Click with termux-sync

If you use Termux on Android as more than a quick toy terminal, you already know how much work goes into getting your setup just right. Over weeks or months, you install dozens of packages, configure Zsh or Bash aliases, clone GitHub repositories, fine-tune SSH keys, and set up Python or Node.js projects. Everything runs smoothly—until you switch to a new Android phone, reset your device, or accidentally break a configuration file.

Rebuilding that entire Termux setup from scratch can easily eat up an entire afternoon. Copying a few files over to /sdcard does not solve the whole problem either, because you still lose your installed package list, file permissions, symlinks, and $PREFIX/etc configurations. That is exactly why termux-sync was created.

Developed by djunekz under the MIT License and actively maintained on GitHub (with over 10,000 downloads on PyPI and version 1.3.9 released in November 2026), termux-sync is an open-source Python CLI and interactive tool built specifically for Termux. With a single workflow, it snapshots your installed packages, home directory, and Termux configuration files into a portable backup—and lets you restore everything cleanly on any Android device.

Why Manual tar Backups Aren't Enough

Many longtime Termux users try to back up their environment with a quick tar command pointed at their home folder. While that saves your scripts and personal files, it misses the bigger picture of what makes your terminal environment work.

When migrating to a new phone or recovering from a wipe, you need more than raw files—you need your installed dpkg package list, your dotfiles, your $PREFIX/etc configs, preserved permissions and symlinks, and a way to verify that the archive wasn't corrupted during transfer. termux-sync wraps all of those steps into a repeatable workflow with SHA-256 checksum verification before restoring.

Key Features of termux-sync

  • Complete Environment Snapshots: Captures your installed Termux packages (via dpkg), your entire home directory (~, including dotfiles, scripts, and projects), and your Termux configuration directory ($PREFIX/etc).
  • Three Flexible Storage Backends: Store backups offline on local device storage (such as /sdcard), sync them to Google Drive via rclone, or push them to a private GitHub repository.
  • SHA-256 Integrity Verification: Generates and verifies SHA-256 checksums for every archive before restoring, so you know your backup is intact before modifying your device.
  • Labeled Backups & Interactive Menu: Run termux-sync with no arguments for a clean interactive menu, or use direct CLI commands with custom labels (for example, --label "before-new-phone").
  • Automated Scheduled Backups: Pairs with Termux:Boot (from F-Droid) to run automatic backups when your Android device starts up.
  • Portable Config & Cleanup Utilities: Includes built-in commands to delete old backups, clear caches, truncate logs, and export or import your termux-sync configuration.

Requirements Before You Start

Before installing termux-sync, make sure your Termux setup is up to date and check which optional tools you need based on where you plan to store your backups:

  • Termux (F-Droid or GitHub build recommended): Avoid the outdated Play Store version so Python, pip, and storage permissions work reliably.
  • Python & pip: Required to run termux-sync.
  • Optional Storage Dependencies:
    • rclone (pkg install rclone) — needed only if you want to store backups on Google Drive.
    • git (pkg install git) — needed only if you want to store backups in a private GitHub repository.
    • Termux:Boot (from F-Droid) — needed only if you want automatic backups on device boot.

Step-by-Step: Installing termux-sync in Termux

Step 1: Install Python and termux-sync via PyPI

The fastest way to get started is installing termux-sync directly from PyPI. First make sure Python is installed, then install rich and termux-sync:

pkg update && pkg install python -y
pip install rich
pip install termux-sync

Step 1: Install termux-sync in Termux

Once installation finishes, you can run termux-sync from anywhere in your terminal. (The repository also offers a tsctl control tool or manual git clone https://github.com/djunekz/termux-sync if you prefer installing from source.)

Step 2: Configure Your Backup Storage Backend

Before taking your first snapshot, run the interactive setup wizard to choose where your backups will live:

termux-sync setup

Step 2: Configure termux-sync storage backend

During setup, you can pick from three backends:

  • Local Storage: Keeps backups offline on your phone's storage for fast restores with zero cloud dependencies.
  • Google Drive (via rclone): Uploads your backup archives to a configured rclone remote.
  • Private GitHub Repository (Recommended for Cloud Sync): Create a private GitHub repository (such as my-termux-backup), generate a fine-grained Personal Access Token limited to that single repository with Contents: Read and write permission, select the GitHub option in termux-sync setup, and enter your token and username/repo.

Backing Up and Restoring Your Termux Environment

Step 3: Create Your First Labeled Backup

Whenever you are about to upgrade major packages, tweak system configs, or switch to a new Android phone, create a labeled backup so you can easily recognize it later:

termux-sync backup --label "before-new-phone"

Step 3: Create a labeled Termux backup

You can also run termux-sync backup without a label if you just want a quick timestamped snapshot. The tool packages your dpkg package list, your home directory, and $PREFIX/etc configs, computes SHA-256 checksums, and saves or uploads the archive to your chosen backend.

Step 4: Restore Your Environment on a New Device

When you set up Termux on a new Android phone (or after reinstalling Termux), install Python and termux-sync, run termux-sync setup to point it to your backup storage, and run:

termux-sync restore

Step 4: Restore Termux environment on a new device

termux-sync verifies the archive's SHA-256 checksum first, then restores your packages, home files, permissions, and Termux configurations—saving you hours of manual reinstallation.

Important Security Tips (Read Before Uploading to the Cloud)

Because a full Termux backup contains your dotfiles, scripts, and personal project directories, treating your backup securely is essential. The official termux-sync Security Policy highlights a few rules every user should follow:

  • Always Use Version 1.3.9 or Newer: Older versions before 1.2.4 had a path-traversal vulnerability during restore (GHSA-259w-wmqg-fp76), and versions prior to 1.3.9 could include ~/.config/termux-sync/config.json (which stores your GitHub token) inside backups. Modern versions (1.3.9+) exclude ~/.config/termux-sync automatically and enforce safe extraction roots.
  • Never Use a Public GitHub Repository: Backups are stored as plain tar archives and are not encrypted by default. Always make sure your GitHub backup repository is set to Private.
  • Use Fine-Grained GitHub Tokens: Restrict your Personal Access Token to only the backup repository with Contents: Read and write access, set an expiration date, and rotate it periodically.
  • Only Restore Trusted Backups: Never restore a backup archive downloaded from an untrusted third-party source.

Useful Maintenance Commands

Besides backing up and restoring, termux-sync includes several handy commands to keep your storage tidy:

  • termux-sync — Launches the interactive menu for all operations.
  • termux-sync delete — Deletes a specific backup you no longer need.
  • termux-sync clear-cache — Cleans temporary cache files selectively.
  • termux-sync clear-logs — Truncates ~/.config/termux-sync/sync.log after confirmation.
  • termux-sync export-config / import-config — Exports or imports your portable configuration.

Final Thoughts

If you rely on Termux for coding, automation, or server management on Android, losing your setup—or spending hours recreating it on a new phone—is frustrating. termux-sync turns Termux migration and disaster recovery into a clean, repeatable two-command habit.

To check out the source code, read the full documentation, or contribute, visit the official GitHub repository:

GitHub Repository: https://github.com/djunekz/termux-sync (MIT License)

Previous Post
No Comments Yet
Add Comment
comment url