I recently migrated app data from multiple Firefox apps from one Android phone to another. At first I tried to rely on Android's device-to-device backup transfer mechanism, but that did not migrate any meaningful Firefox data. I also tried adb backup, but that does not work either (bug 1808763).
What did work is to enable Firefox's remote debugging feature (about:debugging to connect to an Android device) + adb (no root required) to unlock the ability to execute arbitrary JavaScript code in Firefox's main process on the Android device. This enables me to do anything what Firefox is allowed to do, including reading and writing its app data. Which is exactly what we need to create and restore a backup.
The remaining part is the code to actually perform the copy and restore, which I shared at:
https://github.com/Rob--W/firefox-android-backup-restore
Backup instructions: https://github.com/Rob--W/firefox-android-backup-restore#backup
The backup instructions are designed to not consume any space on the source device. The first step is to start a TCP server on your computer to receive the data directly. If you don't have nc (netcat) available on your computer, an alternative is to run a local TCP server on your Android device and then use adb to retrieve the data from it:
adb shell 'nc -l -p 12101 > /sdcard/firefox-android-backup.tar.gz'
adb pull /sdcard/firefox-android-backup.tar.gz
adb shell rm /sdcard/firefox-android-backup.tar.gz
Once the server has been set up, follow the rest of the instructions to run fab_backup_create();
Restore instructions: https://github.com/Rob--W/firefox-android-backup-restore#restore
The first step to restoring is to put the backup archive on the device (replace org.mozilla.firefox if NOT using Firefox release!):
adb shell mkdir /sdcard/Android/data/org.mozilla.firefox/
adb push firefox-android-backup.tar.gz /sdcard/Android/data/org.mozilla.firefox/
The default instructions are for Firefox release (org.mozilla.firefox), but if you want to restore to a different app, replace org.mozilla.firefox with:
org.mozilla.firefox - Firefox Release
org.mozilla.firefox_beta - Firefox Beta
org.mozilla.fenix - Firefox Nightly
org.mozilla.focus - Firefox Focus
Once the backup has been uploaded to the device, restore it by following the rest of the instructions to run fab_backup_restore();
I have tested this with all Firefox apps (versions 118 - 120), on Android 12 and Android 14, on Google Pixel 3 and Google Pixel 8.