doronz88 / pymobiledevice3

Pure python3 implementation for working with iDevices (iPhone, etc...).
https://discord.gg/52mZGC3JXJ
GNU General Public License v3.0
1.16k stars 160 forks source link

Question: how to make full device backup over network (no USB) as a regular Linux user #1076

Open avibrazil opened 2 weeks ago

avibrazil commented 2 weeks ago

Documentation doesn't explain this.

I'd like to have a home backup server for my iOS devices.

I can initialize things with a USB cable and root user, but subsequent connections and backups I'd like to make them as a regular user, wirelessly.

I also expect subsequent backups will be incremental.

How to setup this environment? Or would you please point me to instructions on how to do that ?

Thank you in advance

doronz88 commented 2 weeks ago

Unfortunately, usbmuxd on linux doesn't support wifi connections. However, if your device iOS > 17.0, you may do the backup over it instead which supports wifi.

avibrazil commented 2 weeks ago

I’m 17.5

How to make backups over WiFi? Documentation isn’t clear and I was only able to make it over cable.

avibrazil commented 2 weeks ago

How to open the device for network connections, how to keep the device open, how to network connect and start backups?

jordus100 commented 2 weeks ago

tunneld which is run with pymobiledevice3 remote tunneld command by default will try to connect (establish tunnels) to your iPhone over Wi-Fi when the device is unplugged from USB and in the same LAN. You just need to be connected via USB to pair for the first time.

avibrazil commented 2 weeks ago

I just need to leave pymobiledevice3 remote tunneld running and it will automatically connect to the device every time it is on same LAN? Even when the device leaves and comes back? Then how to start backups over the network? The backup2 command doesn’t accept the IP and port parameters, as far as I can check.

In the readme, only place that pymobiledevice3 remote tunneld is mentioned is referring Windows and that’s why I ignored it. Very confusing.

doronz88 commented 2 weeks ago

Just add --tunnel UDID to any command to make it use the tunnel. You can also just add --tunnel '' and if there are multiple devices connected, it will prompt for which to connect to

avibrazil commented 2 weeks ago
$ pymobiledevice3 backup2 backup --full --tunnel ""
2024-06-20 07:17:41 hostname pymobiledevice3.__main__[834623] ERROR Device is not connected

This device was connected via USB cable before to this pymobiledevice installation on this computer and all trust requested was approved. Now this trial was wireless.

———

Can someone please provide all the sequence of steps required to make wireless incremental iOS backups to a Linux host with iOS>=17, including which Linux user must be used for each command (security and privilege concerns) for initial setup (with cable?) and then the everyday backups (wireless?) ?

I’m an advanced, experienced Linux and Python and iOS user, but still I can’t make it work because of poor and scattered documentation. If I can’t do it, I bet nobody except the original developers won’t be able to do it either with current documentation.

I can provide a patch (pull request) to readme with the full process and steps once I manage to make it work because I think this is important and more users need access to this functionality.

Thank you in advance

doronz88 commented 2 weeks ago

Make sure you enabled the device for wifi connections:

pymobiledevice3 lockdown wifi-connections on

Afterwards, you should be able to see tunneld just creating a tunnel to the device as soon as it discovers it over bonjour

avibrazil commented 1 week ago
pymobiledevice3 lockdown wifi-connections on

Still doesn't work

Would you mind putting in one comment here the sequence of commands to pair with cable, disconnect cable and then do a full wireless backup on Linux, specifying which user has permission to execute command on each step ?

Everything works with cable connected. Once I disconnect, all stops working. I also revisited the readme, which still doesn't work for me.

Thank you in advance

jordus100 commented 2 days ago

Make sure you enabled the device for wifi connections:

pymobiledevice3 lockdown wifi-connections on

Afterwards, you should be able to see tunneld just creating a tunnel to the device as soon as it discovers it over bonjour

Lockdown wifi tunnels still go through usbmuxd and its Unix socket, don't they? I suspect they won't work on Linux because of lack of a proper wireless usbmuxd implementation.

However, if your device iOS > 17.0, you may do the backup over it instead which supports wifi.

AFAIK that first requires pairing and establishing a USB-over-Ethernet tunnel, so OP needs the custom Linux driver to do the first-time cable pairing.

avibrazil commented 2 days ago

I'm starting to suspect that wireless is currently impossible under Linux due to usbmuxd limitations.

And everything that people answered here about how to operate wirelessly was on other platforms, Windows, macOS etc.

Can anyone confirm this please?

jordus100 commented 1 day ago

I've done wireless on Linux on a custom kernel version as described in the thread https://github.com/doronz88/pymobiledevice3/issues/566 and it certainly works. To not use the custom kernel patch I think you can use go-ios https://github.com/danielpaulus/go-ios , they seem to have created a userspace driver in golang.