Restore Home Folder, full functionality

I broke my phone again. Damn slippery things. The screen is completely broken. Fortunately, I did a full backup of the complete /home partition the same day, and I had it restored with full functionality on a spare device (with a half broken screen) less than 24h later.

Backup

I created the backup - while the GUI was running - with this little script:

#!/bin/sh

backupdir="/home"
outputdir="/home/defaultuser/Downloads"
outfile="$outputdir/backup-$(date '+%Y%m%d%H%M').tar.gz"

echo "Will make a full backup of $backupdir, stored in $outputdir"

devel-su tar --totals --exclude="$outfile" -c -z -f "$outfile" "$backupdir"

echo "Backup saved as $outfile"

Restore

The destination device is a factory-reset SFOS device (doesn’t matter which one afaics, everything here is architecture- and hardware-agnostic), registered and updated to the same version as the one the backup came from (but maybe that’s irrelevant too, as long as the versions don’t differ too much I guess).

The gzipped tar backup is located on an inserted sdcard.

To avoid all sorts of trouble with the GUI running I boot into recovery and telnet into the device via USB, then open a shell.

cryptsetup open /dev/mapper/sailfish-home myhome
mount -m /dev/mapper/myhome /mnt/myhome
mount -m /dev/mmcblk1p1 /mnt/sdcard
cd /mnt/myhome
mv defaultuser defaultuser.bak
tar xcf ../sdcard/backup-nnnnnnnnnnnn.tar.gz home/defaultuser
mv home/defaultuser .
rmdir home
umount /mnt/*
cryptsetup close /dev/mapper/myhome
exit

You might have to check whether /dev/mmcblk1p1 is really the partition you want. Do so with fdisk -l.

As you can see we only restored the defaultuser part. I don’t think it would have made sense
to restore the other folders.

Now reboot in accordance with the docs. That’s it. I still need to reinstall software, but everything works: accounts, configurations, contacts, calendars, downloaded podcasts… it’s all there, except for Signal which I had to restore from its own backup.

After 1 or 2 reboots I deleted /home/defaultuser.bak.

8 Likes

If you are willing to do, also restore /var/lib/bluetooth to restore the BT list as well as the /var/lib/waydroid → /home/waydroid symlink and folders in case you had those

(there’s also some for AAS etc)

1 Like

In retrospect I should’ve tried restoring all folders in /home (appsupport, system) except those related to packagemanagement (*zypp*). Ah well, next time.

1 Like