Using 2 factor authentication generally is a good idea. However, losing 2 factor data can be the opposite. If you’re using Google Authenticator to generate 2FA codes, you may have wondered how to backup the data the app uses to generate codes. The method described here requires root access of course but doesn’t require a third party app. Please note that you can always use apps that backup app data but recovering this data on newer Android versions can fail. To avoid this, use this script:
#!/bin/bash # $1: IP adb root adb connect $1:5555 adb pull /data/data/com.google.android.apps.authenticator2/databases/databases /tmp/.bkp sqlite3 /tmp/.bkp "select * from accounts;" rm /tmp/.bkp
This pulls the SQLite database of Google Authenticator and prints all secret data. You can then use the printed data to backup your Authenticator state and to recover it later in case other restoring mechanisms fail.