✏ Creating a backup of user data using TWRP community edition

This is a wiki post. Everyone can improve it, by clicking the green pencil above.


This is a full guide on how to create a full backup of data and cache partitions on a Fairphone 2. We use the backup functionality of TWRP. Full backups are a great way to store a duplicate of all your important information on your PC. This way, if your Fairphone 2 is damaged or lost, you can go back to the previous state of the phone which is stored in the backup.

Prerequisites

The instructions below assume that you have an adb connection between your PC and your Fairphone. To set this up, you need to do the following:

  • On Windows: Follow the instructions here: ✏ How to use ADB on the FP2
  • On Linux (Ubuntu or similar):
    1. Install the required packages: sudo apt install adb fastboot
    2. A reboot might be required to actually get access to the device.
    3. Follow step 1 in the linked Windows instructions to enable adb access on your phone.

All commands highlighted like this need to be typed into the commandline where ADB and fastboot are available (according to the instructions above).

1. Installing latest TWRP

  1. Backup your data! We try to be as clear as possible, but accidents can always happen when modifying your phone on the level we are here.
  2. Install the latest TWRP. _For details and extra information look here: https://forum.fairphone.com/t/pencil2-using-twrp-on-the-fairphone-2/29452_
    1. Download the latest version of TWRP Primary (Europe) or Primary (Americas) whichever is preferred and available.
    2. Connect your Fairphone 2 with your computer using a USB cable.
    3. Reboot your Fairphone into the bootloader: adb reboot bootloader
    4. Flash TWRP: fastboot flash recovery twrp-3.2.3-0-FP2.img (change the filename to the version you downloaded)
    5. Type — without pressing enter yet — fastboot reboot
    6. Hold the volume up button on your phone and press enter on your PC.
    7. Keep holding the volume up button on the phone until the TWRP screen shows up (approximately 15 seconds when I tested this).
    8. You should end up on a screen that is similar to the recovery we are using for Android 7.

Compare the displayed version number to verify that you successfully booted into your desired version of TWRP.

2. Creating a Backup of data partition

The data partition contains all your data (apps, pictures, accounts, etc.). A backup of this partition is what you need to restore your phone to a previous state. All other partitions can always be downloaded from Fairphone Support pages, should you ever need them (which is unlikely).

:warning: Please note that /data/media, the internal storage (which contains data like your pictures and music) is NOT backed up by TWRP. So please do a separate backup of all your media files!
:warning: These files can be copied using the usual methods to access files on the phone, for example over USB. If files appear to be missing in USB mode, Android’s file index may have gotten stuck - deleting data for media storage (Settings > Apps) forces a rebuild of the index (this may take some time). You can also find a workaround to back up the internal storage with the TWRP backup under twrpstoragebackup.

Prerequisite: Depending on the amount of data you have on your phone, an SD card with 32GB might be necessary for the backup.

  1. Get a backup of your data partition through TWRP
    1. Make sure you booted into TWRP (Step 7 above)
    2. Press Keep Read Only
    3. Press Backup
    4. Select partitions to backup:
      • Select Data
      • make sure Boot and System are not selected
    5. Press Select Storage — if there is an option, select the SD card instead of Internal Storage
    6. On the bottom Swipe to Backup. This process might take long and you might want to charge your phone at the same time. If you screen turns off, just press the power button and Swipe to Unlock to keep seeing progress.
    7. Wait until it’s done. Press Reboot System, then Do Not Install.
  2. Copy the backup to you PC
    1. Connect your phone to your PC and set its USB mode to file transfer
    2. Navigate to the storage you previously selected - Internal Storage or your SD card
    3. In there, navigate to TWRP/BACKUPS/<device serial> (where <device serial> is the serial number of your phone). There should only be one folder in BACKUP, just use this one.
    4. Copy the directory with the latest date from your phone to your PC.

3. Restoring previously backed up data

If you ever want to restore a backup, you also need to have TWRP installed. Follow the steps above in section Installing latest TWRP.

Note: This erases data on the phone by replacing it with data in the backup!

  1. Copy the backup to the phone
    • Copy it to an SD card which you insert into your Fairphone 2 or
    • Connect your Fairphone 2 with your computer and copy the backup directly to the phone.
  2. Boot into TWRP (last step of Installing latest TWRP).
  3. Press Keep Read Only
  4. Press Restore
  5. Navigate to the folder in which you stored the backup file
    • Press Select Storage to switch between internal storage and SD card
    • Press a folder name to go into a folder
    • Press (Up A Level) to go to a parent folder.
  6. When you have found the backup file, press the file name
  7. Select the partitions to restore.
    • NB: If your backup is a LineageOS 17.1 one, when restoring it, please install the system anew before restoring only the Data partition (don’t reboot in between). The restore of the system is broken in LineageOS 17.1 and will result in being stuck on the boot screen. You can find here how to install LineageOS 17. on FP2.
  8. Swipe to Restore.

This process can take a while. Wait until it is finished and then follow the instructions to restart your Fairphone 2.

8 Likes