How to swap an encrypted SD card without losing data? I have a Fairphone 2 running their OpenOS.  It is Google-free and rooted.  I have a 128GB SD card installed, added to the 32GB that comes with the phone.

I suspect that my SD card might be failing.  I would like to test this by switching to a new card.  I do have a 64GB card I can use, and I do have enough free space that it'll all fit.

The question is, how?  I use both TWRP and Titanium Backup, but neither of them backs up the majority of my data.  They basically just do apps.

I can rsync from the phone to a computer, but it's far from clear how I would restore.  I guess I'd end up having to piece things back together one directory at a time.

I really want something that will backup and restore the entire phone.  Is there any way to do this cleanly?

Alternatively, is there any way to fsck the SD card?
As your device is rooted a complete backup of the sdcard to your PC is IMHO the best option:

First enable ADB on your device and connect it to your PC that has ADB installed

Second check via adb shell that the tar command is available. If not you can install for example the BusyBox app.

Now open a terminal/or commandline (Linux/Windows) on your PC and execute the following command:

adb exec-out "su -c 'tar c /sdcard/*'" &gt; sdcard.tar


Or without root:

adb exec-out "cd /sdcard &amp;&amp; tar c *" &gt; sdcard.tar


This will create a tar file in the current directory on your PC with the complete content of your sd-card. Note: If your sd-card is not accessible via /sdcard replace this part of the command with the correct path. 

Now you have a full backup of your sd-card. Check it using an archive tool. 
Using tar you can write it back similar to how it was created or you extract the relevant files and write them back manually via adb or MTP protocol.