My input is providing a guide to properly create and restore from local backup.
Creating a local backup
- Creates a tar archive of the
com.whatsapp directory
adb shell "cd /sdcard/Android/media/ && tar -cf /sdcard/whatsapp.tar com.whatsapp"
- Verify:
$ adb shell ls /sdcard/whatsapp.tar
/sdcard/whatsapp.tar
- Pull the archive and saves it to your computer:
adb pull /sdcard/whatsapp.tar ~/Downloads/whatsapp/
To verify that the whatsapp.tar archive contains the exact same data as the source directory on the phone, we can generate a checksum for every file in both locations and compare them.
- Generate checksums on the phone
adb shell "cd /sdcard/Android/media/ && find com.whatsapp -type f -exec sha256sum {} +" > phone_hashes.txt
Extract the archive we copied from phone to computer earlier:
cd ~/Downloads/whatsapp/
tar -xf whatsapp.tar
Generate checksums on the computer
find com.whatsapp -type f -exec sha256sum {} + > computer_hashes.txt
Compare the two sorted lists
sort phone_hashes.txt -o phone_hashes.txt
sort computer_hashes.txt -o computer_hashes.txt
diff phone_hashes.txt computer_hashes.txt
The diff command should produce no output.
Restoring backup
After flashing GrapheneOS, do the following:
Install Whatsapp on the new phone but don't open it
Run the following commands
adb shell mkdir -p /sdcard/Android/media/com.whatsapp
adb push ~/Downloads/whatsapp/whatsapp.tar /sdcard/Android/media/com.whatsapp/
- Extract the archive
adb shell "cd /sdcard/Android/media/com.whatsapp/ && tar -xvf whatsapp.tar"
- Move all content from the nested directories
adb shell mv "/sdcard/Android/media/com.whatsapp/com.whatsapp/WhatsApp/*" "/sdcard/Android/media/com.whatsapp/"
- Remove the now empty nested directory
adb shell rm -r "/sdcard/Android/media/com.whatsapp/com.whatsapp"
- Check we have the correct directory structure
➜ adb shell ls -a /sdcard/Android/media/com.whatsapp/
.Shared
.StickerThumbs
.Thumbs
.trash
Backups
Databases
Media
Go to Settings -> App and Choose "Google Play Service" to allow all permission (for now)
Open Whatsapp, before you do anything else, go to App Whatsapp and allow all permission (for now)
Open Whatsapp again, choose language.
Turn on airplane mode immediately to block Whatsapp from contacting Google's services.
A prompt should pop up. Press Skip, and you should be prompted to restore from a local backup.
After verifying the backup is restored, we can remove the tar:
adb shell rm /sdcard/Android/media/com.whatsapp/whatsapp.tar