Git Product home page Git Product logo

ipibackup's Introduction

iPibackup: backup your iPhone while charging it

Introduction

This project aims to provide a simple and transparent way to backup an Apple iPhone (or iPad) while charging it (for example at night).

For people who don't use iCloud backups or iTunes backups over Wi-Fi, backup frequency can be rather low. Backups should the most simple and transparent possible, or one won't do it at all (and regret it later).

Fortunately, thanks to a combination of software (like libimobiledevice) and hardware (like a Raspberry Pi Zero) it's possible to create a device which will both charge and back your phone, every time you plug it.

Note: That also means it's quite easy to do that with anything that looks like a phone charger. Don't plug your phone to random stuff. If you're asked to trust something and type your passcode, that will give access to your phone to anything at the other side of the cable. Including that speaker/alarm in your hotel room (no, you don't need to type your passcode just to transmit music)

Setup

Hardware

Just pick any computer you'd like to dedicate to this. I think the best candidates are all the single board computers available these days, and I especially like the Raspberry Pi Zero for that, so all this README assumes that target device, but it should be trivial to port it to other devices.

The Raspberry Pi Zero has two micro-USB port: one for power, one for an USB device. We'll use the former to provide power to the RPi, and the latter to provide charging power to the iPhone and take the backup. Be sure to also pick a good power supply and a micro-USB male to USB-B female adapter (or a micro-USB male to lightning adapter, but a cable might be more flexible).

Also pick a micro-SD card large enough to host both the system (current Raspbian lite uses around 1GB and it should be quite possible to strip it more) and your backup. Since the Raspberry Pi Zero only has one usable USB port, we have to use the micro-SD card for everything. If you use a different device with more USB port then you can also use a standard USB key.

I had good success with the Melopero Raspberry Pi Zero W starter kit:

Setup picture

Software

System preparation

Download the latest Rasbian lite and unzip it:

$ wget https://downloads.raspberrypi.org/raspbian_lite_latest
$ unzip raspbian_lite_latest

Then burn the resulting image to your micro-SD card (adjust file and device names):

# dd if=2019-07-10-raspbian-buster-lite.img of=/dev/mmcblk0 bs=4M

To make the backup easily available to MacOS and Windows computer, we also create a separate FAT32 partition for hosting the backup files. Restore can be done by taking the micro-SD card to a full computer running either iTunes or idevicebackup2.

# echo "start=1G,type=c" |  sfdisk -a /dev/mmcblk0
# mkfs.vfat -n PIBACKUP /dev/mmcblk0p3

System configuration

Note: Current Raspbian lite doesn't include some specific software we need, so we'll have to install it manually. That means if we only have a Raspberry Pi Zero with no way to connect to the Internet, things are starting to get a bit ugly. My workaround was to first to the setup using a Raspberry Pi 2, then put the SD card in the Zero.

Boot the just burned SD-card and log in (either on an attached keyboard and screen, on an UART or remotely over SSH if you can plug it to a network; Raspberry Pi Zero headless setup can be helpful here too)

You can adjust some parameters (locales, timezone etc.) using raspi-config as root. We'll also allocate more power to the USB port so charging is a bit faster (I didn't measure it and I don't really care since it charges at night, but by default I think the USB port won't provide more than 500mA which is really low)

# echo max_usb_current=1 >> /boot/config.txt

libimobiledevice as included in Debian Stretch didn't support iOS 11 but current (as of Septembre 2019) Raspbian versions are based on Buster which work fine even with iOS 13.

# apt update
# apt install libimobiledevice-utils

We also need to mount the partition created above at the correct place:

# su pi -c "mkdir /home/pi/iphone"
# echo "LABEL=PIBACKUP  /home/pi/iphone vfat  defaults,noatime,nodev,nosuid,noexec,uid=1000,gid=1000  0 1" >> /etc/fstab
# mount /home/pi/iphone

Service configuration

The backup itself is done using a simple systemd unit file. Drop it into /etc/systemd/system and enable it with:

# systemctl enable ipibackup

Usage

Backup

Just plug an iPhone (using a standard lightning cable plus the USB female adapter). When asked by the system, chose Trust and enter your passcode. The backup should start after few seconds. The syncing indicator (spinning arrows next to the wireless or cellular indicator) will stay on during the whole backup. The initial one will take some time, especially if you have a lot of data on your iPhone, but subsequent ones will be faster.

The backup is stored in /home/pi/iphone in a subdirectory identified by the iPhone serial number.

Note It's really recommended to configure a backup password on the iPhone (either on iTunes or using idevicebackup2 -i encryption on). That way the backup content is encrypted on the SD card, and the backup itself contains more data (like the keychain content)

Direct feedback and debug

If it doesn't work, it really helps having remote access to the charger and look at the journal (journalctl -f) when doing a backup.

The unit file also has support for lighting a LED on GPIO#18 when backup starts, and switching off when it's done, so you can also solder one (don't forget the resistor).

Restore

If you need to do a restore, you can just put the microSD card in a different computer, plug your iPhone and do the restore from there, using:

$ idevicebackup2 -i --system --reboot restore /path/to/backup/folder

Also, make sure you have enough free space on your device to store the backup archive in it. The program idevicebackup2 will copy all the data and make sure the restoration data integrity is ok before switching to the backup you want to restore.

On a MacOS or Windows computer, you can copy the content of the backup folder (the folder with a long alphanumeric name, corresponding to your iPhone identifier) to the iTunes folder. On MacOS it should be ~/Library/Application Support/MobileSync/Backup/ while on Windows it should be \Users\(username)\AppData\Roaming\Apple Computer\MobileSync\Backup\. More information can be found on the dedicated Apple support page

Future work

Some ideas for the future:

  • move backup to separate, VFAT partition for easier MacOS/Windows restore
  • support remote backup host (maybe using sshfs?)
  • investigate various HAT, pHAT and shims for user feedback (e.g Pimoroni buttons shim)
  • find a way to get and report backup failure

ipibackup's People

Contributors

corsac-s avatar francois-contat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ipibackup's Issues

Accesories bug

When i plug my iPhone 8 into the pi it says the accesories dosen't work with it i dont know why

Device is not ready yet. Going to try again in 2 seconds...

I followed the described steps exactly using a Raspberry Pi 3B instead of a Raspberry Pi Zero. However, when I connect my iPhone Xs (iOS 12.4.1), the backup does not start.

I connected to my Raspberry Pi via SSH and used journalctl -f to see logs. After connecting the iPhone, I could read Device is not ready yet. Going to try again in 2 seconds... there over and over. What is the problem here?

Unable to enable ipibackup.service

I've followed your steps and put the .service file in /etc/systemd/system and when I do sudo systemctl enabele ipiconfig it returns this error:
Failed to enable unit: File ipibackup.service: Invalid argument

backup images only

thanks for this great idea. I would like to backup pictures from my iphone, not the whole disk. I see this uses idevicebackup2 and looking at it's options it seems to be an all-or-nothing type of backup tool, there's no way to limit it to just pictures. any idea if this is possible and what tool I should use?

Status LED

I would like to have four status LEDs instead of one, so that they can show the percent progress of the backup (1 LED on = 25 %, 2 LEDs on = 50 %,...). Is that somehow possible with idevicebackup2? If so, can you give me a hint, how to realize that?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.