Termux backup

It's a good idea not to lose the termux seup that you spent so long getting "just right".
Thankfully backing it up is quite simple.

Just paste this into a file (e.g. backup.sh) in your termux environment.
chmod +x to make it executable.
Then ./backup.sh will create a backup file in the location set in the $base variable that is set inside the file base="/storage/emulated/0/Documents/termux-backup". The backup will be date stamped.

#! /bin/bash

now=$(date)
read -a fn <<< "$now"
base="/storage/emulated/0/Documents/termux-backup"

#echo "$base${fn[5]}${fn[1]}${fn[2]}.tar.gz"
tar -zcf "$base"${fn[5]}${fn[1]}${fn[2]}.tar.gz -C /data/data/com.termux/files ./home ./usr

exit 0

You'll have to manage the number of backups for yourself, there is no limit set within the script to how many copies you might have building up.

Restoring is a matter of running
tar -zxf {base}{date}.tar.gz -C /data/data/com.termux/files --recursive-unlink --preserve-permissions
Where {base} is the variable from above - or the location & base name of the file if you moved it - with the relevant date for the backup that you want to restore.

This is really just a convenience script implementing the process given here:

Backing up Termux - Termux Wiki