This is a guide on how to backup and restore any Termux distro without losing folders and files permissions
Youtube Tutorial
Backup
- Make sure your distro root folders (es. /dev, /proc) can be read by the owner
- If not, change the permissions of the folders to (400)
- Use the following command to backup your Termux "home" and "usr" folder
(you can change your preferred destination for the backup instead of the sdcard root)
cd /data/data/com.termux/files
tar --format=gnu -pzcf /sdcard/termux-backup.tar.gz home usr
Restore
- Make sure to have storage permissions and the latest version of your Termux packages (supposing you have just installed Termux)
termux-setup-storage
pkg update && pkg upgrade
- Restore the "home" folder with the following commands:
cd /data/data/com.termux/files
rm -rf home
tar --same-owner -pzxf /sdcard/termux-backup.tar.gz home
- Then restore the "usr" folder as well
cd /data/data/com.termux/files
cp ./usr/bin/busybox ./tar
rm -rf usr
unset LD_PRELOAD
./tar -zxf /sdcard/termux-backup.tar.gz usr
exit
- You did it! You successfully restored your Termux distro!
- Termux official backup instructions (this guide doesn't mantain permissions): https://wiki.termux.com/wiki/Backing_up_Termux