adb backups fail with "Internal exception during full backup" For a while now, I've not been able to create a full adb backup of my Nexus 4.

Now finally I've been able to catch a slightly more useful error report with logcat:

D/BackupManagerService( 2061): Calling doFullBackup() on de.blinkt.openvpn
I/file_backup_helper( 9115):    Name: apps/de.blinkt.openvpn/r/app_webview
I/file_backup_helper( 9115):    Name: apps/de.blinkt.openvpn/r/app_webview/Web Data-journal
I/file_backup_helper( 9115):    Name: apps/de.blinkt.openvpn/r/app_webview/Web Data
I/file_backup_helper( 9115):    Name: apps/de.blinkt.openvpn/r/app_webview/paks
I/file_backup_helper( 9115):    Name: apps/de.blinkt.openvpn/f/8b8192c9-4aa3-42b3-affb-fd49fc7044d7.vp
I/file_backup_helper( 9115):    Name: apps/de.blinkt.openvpn/sp/WebViewChromiumPrefs.xml
I/file_backup_helper( 9115):    Name: apps/de.blinkt.openvpn/sp/activities.LogWindow.xml
I/file_backup_helper( 9115):    Name: apps/de.blinkt.openvpn/sp/de.blinkt.openvpn_preferences.xml
I/file_backup_helper( 9115):    Name: apps/de.blinkt.openvpn/sp/VPNList.xml
I/art     ( 2268): Wrote stack traces to '/data/anr/traces.txt'
I/art     ( 2288): Wrote stack traces to '/data/anr/traces.txt'
I/art     ( 2717): Wrote stack traces to '/data/anr/traces.txt'
I/art     ( 2061): Explicit concurrent mark sweep GC freed 217771(9MB) AllocSpace objects, 32(1594KB) LOS objects, 33% fr
ee, 29MB/44MB, paused 2.136ms total 158.660ms
E/BackupManagerService( 2061): Internal exception during full backup
E/BackupManagerService( 2061): java.lang.ArrayIndexOutOfBoundsException: length=32768; regionStart=0; regionLength=-1
E/BackupManagerService( 2061):  at java.util.Arrays.checkOffsetAndCount(Arrays.java:1719)
E/BackupManagerService( 2061):  at java.util.zip.DeflaterOutputStream.write(DeflaterOutputStream.java:174)
E/BackupManagerService( 2061):  at com.android.server.backup.BackupManagerService.routeSocketDataToOutput(BackupManagerSe
rvice.java:3135)
E/BackupManagerService( 2061):  at com.android.server.backup.BackupManagerService.access$900(BackupManagerService.java:15
8)
E/BackupManagerService( 2061):  at com.android.server.backup.BackupManagerService$FullBackupEngine.backupOnePackage(Backu
pManagerService.java:3271)
E/BackupManagerService( 2061):  at com.android.server.backup.BackupManagerService$PerformAdbBackupTask.run(BackupManagerS
ervice.java:3849)
E/BackupManagerService( 2061):  at java.lang.Thread.run(Thread.java:818)
D/BackupManagerService( 2061): Full backup processing complete.
D/bu      ( 6589): Finished.
D/AndroidRuntime( 6589): Shutting down VM
D/BackupManagerService( 2061): Full backup pass complete.


I'm running CyanogenMod 12.1-20151007-SNAPSHOT-YOG4PAO334-mako. This problem started a few releases earlier though.

My Android file system is encrypted. I usually run the backup like this:

adb backup -apk -shared -system -all -f "adb-backup.$(date +"%Y%m%d").ab"


Any ideas?

(BTW, I think the fact that OpenVPN was being backed up just before the issue is probably a red herring)
While I was typing up the question I managed to finish a full backup. I used the -nocompress flag (which isn't documented in the help for adb), and used the same passphrase for the backup as for my Android file system encryption.

So, this was the full command:

adb backup -nocompress -apk -shared -system -all -f "adb-backup.$(date +"%Y%m%d").ab"


logcat:

...
I/file_backup_helper( 6652):    Name: shared/0/0/Ringtones
I/file_backup_helper( 6652):    Name: shared/0/0/Ringtones/hangouts_incoming_call.ogg
I/file_backup_helper( 6652):    Name: shared/0/0/Ringtones/hangouts_video_call.ogg
I/file_backup_helper( 6652):    Name: shared/0/0/Ringtones/hangouts_message.ogg
I/file_backup_helper( 6652):    Name: shared/0/0/Podcasts
I/file_backup_helper( 6652):    Name: shared/0/0/Music
D/BackupManagerService( 2061): Full package backup success: com.android.sharedstoragebackup
D/BackupManagerService( 2061): Full backup processing complete.
D/bu      ( 9722): Finished.
D/AndroidRuntime( 9722): Shutting down VM
D/BackupManagerService( 2061): Full backup pass complete.