Follow below steps to migrate the setup of Termux from Device A to Device B
Step 1. Backup termux on device A and run below command one by one.
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
Step 2. Restore the setup of Termux on Device B.