Follow below steps to migrate the setup of Termux from Device A to Device B
For termux, ~/storage
folder contains a bunch of the soft links
external-n
is the one pointing to the MicroSD card or the OTG USB Drive, using realpath ~/storage/external-1
, can get the physical path on the MicroSD card. The XXXX-YYYY part is the MicroSD card UUID
Other links, such as dcim, movies, music
, they are pointing to the folders on the phone internal storage, using realpath ~/storage/dcim
can find the physical location of the folder
- Most of the time, the internal storage are something like
/storage/emulated/0
- The microSD card would be something like
/data/XXXX-YYYY/Android.data/com.termux/files
cd /data/data/com.termux/files
tar -zcvf ./termux-backup_20211031.tar.gz home usr
mv ./termux-backup_20211031.tar.gz /storage/[Device A ID]/Android/data/com.termux/files/termux-backup_20211031.tar.gz
- Use a bluetooth keyboard to connect to the device B
- Open the termux app
- Grant the storage permission to the MicroSD card with command
termux-setup-storage
, and click "Allow" - Go to the termux root folder with
cd /data/data/com.termux/files
- Using the first part of the instruction to get the [Device B ID], the MicroSD ID usually looks like XXXX-YYYY
- Copy the backup file to the termux root folder:
cp /storage/[Device B ID]/Android/data/com.termux/files/termux-backup_20211031.tar.gz .
- Override the current home and usr folder with
tar -zxvf ./termux-backup.tar.gz home && tar -zxvf termux-backup.tar.gz usr
Restart the Termux and see if all the setup are in place on device B.
Replace any script/soft link using the /storage/[Device A ID]
to /storage/[Device B ID]