Skip to main content

How to back up and restore Termux files

·
Categories Smartphones Termux Tutorials
Table of Contents

If you often uninstall Termux for testing purposes, you need to know how to back up Termux’s files so you can quickly restore them after reinstalling. Root privileges are not required.

Referenced from the Termux WiKi

1. Back up Termux files
#

Besides personal use, Termux backup archives can also be provided to other people, which is the so-called “recovery package”.

  1. Get storage permission
termux-setup-storage
  1. Create a backup archive. This command backs up the data in Termux’s external directories, not including proot-distro. If the Termux data takes up 10GB of space, the backup takes about 10 minutes and the archive size is about 5GB.
tar -zcf /sdcard/termux-backup.tar.gz -C /data/data/com.termux/files ./home ./usr

Without root privileges, you can only use the proot-distro backup command to back up Proot-distro data separately:

proot-distro backup --output /sdcard/debianbackup.tar.gz debian

If you have root privileges, the following version of the command can back up the data inside Proot-distro’s internal directories into a single file as well, with no need to use proot-distro backup.

pkg install tsu
sudo tar -zcf /sdcard/termux-backup.tar.gz -C /data/data/com.termux/files ./home ./usr

2. Restore Termux backup files
#

Restoring a Termux backup does not require root privileges.

  1. First get storage permission
termux-setup-storage
  1. Suppose the backup file is located at internal storage/termux-backup.tar.gz; restore it and restore permissions. After running this command, the data will be overwritten.
tar -zxf /sdcard/termux-backup.tar.gz -C /data/data/com.termux/files --recursive-unlink --preserve-permissions
  1. Enter exit to quit Termux. Reopen the app and the files will be back.

To restore the separately backed-up Proot-distro, run:

proot-distro restore /sdcard/debianbackup.tar.gz

Related


Thank you for reading. Public comments are not available on this website. I write to explore ideas honestly, not to chase social engagement or traffic. I would be glad to hear your thoughts after reading the article with care. If you found any errors, technical issues, or would like to share feedback, feel free to contact me via the email listed on the About page.