pymobiledevice3
pymobiledevice3 copied to clipboard
Question: how to make full device backup over network (no USB) as a regular Linux user
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
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.
I’m 17.5
How to make backups over WiFi? Documentation isn’t clear and I was only able to make it over cable.
How to open the device for network connections, how to keep the device open, how to network connect and start backups?
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.
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.
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
$ 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
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
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
Make sure you enabled the device for wifi connections:
pymobiledevice3 lockdown wifi-connections onAfterwards, you should be able to see
tunneldjust 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.
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?
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.
What's the status on this? I've so far gotten to the stage where I have communications over wifi via tunneld, but the backup command seems to be failing
$ pymobiledevice3 backup2 backup --rsd fd29:4998:c39::1 61328 iphone_backup
Traceback (most recent call last):
File "/home/dex/.local/bin/pymobiledevice3", line 8, in <module>
sys.exit(main())
File "/home/dex/.local/lib/python3.10/site-packages/pymobiledevice3/__main__.py", line 110, in main
cli()
File "/home/dex/.local/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
File "/home/dex/.local/lib/python3.10/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
File "/home/dex/.local/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/dex/.local/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/dex/.local/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/dex/.local/lib/python3.10/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "/home/dex/.local/lib/python3.10/site-packages/pymobiledevice3/cli/cli_common.py", line 150, in wrap_callback_calling
callback(service_provider=service_provider, **kwargs)
File "/home/dex/.local/lib/python3.10/site-packages/pymobiledevice3/cli/backup.py", line 40, in backup
backup_client = Mobilebackup2Service(service_provider)
File "/home/dex/.local/lib/python3.10/site-packages/pymobiledevice3/services/mobilebackup2.py", line 39, in __init__
super().__init__(lockdown, self.RSD_SERVICE_NAME, include_escrow_bag=True)
File "/home/dex/.local/lib/python3.10/site-packages/pymobiledevice3/services/lockdown_service.py", line 20, in __init__
service = start_service(service_name, include_escrow_bag=include_escrow_bag)
File "/home/dex/.local/lib/python3.10/site-packages/pymobiledevice3/remote/remote_service_discovery.py", line 81, in start_lockdown_service
checkin['EscrowBag'] = base64.b64decode(pairing_record['remote_unlock_host_key'])
TypeError: 'NoneType' object is not subscriptable
@me-dex re-pair over rsd.
rm -rf ~/.pymobiledevice3
@doronz88 Tried to re-pair with rsd, but the device isn't showing up during the scan
$ pymobiledevice3 bonjour rsd
[]
It does show up under remotepairing and mobdev2 though -
$ pymobiledevice3 bonjour remotepairing
[
{
"hostname": "172.20.10.1",
"port": 49152
}
]
I am getting output from rsd-info though
$ pymobiledevice3 remote rsd-info
{
"MessageType": "Handshake",
"MessagingProtocolVersion": 3,
"Properties": {
"AppleInternal": false,
"BoardId": 14,
...
remote browse is also showing nothing
$ pymobiledevice3 remote browse
{
"usb": [],
"wifi": []
}
iOS version: 17.7
@avibrazil Have you tried to use https://github.com/tihmstar/usbmuxd2 ? It's a usbmuxd re-implementation for Linux which supports wifi. However, it might have a compatibility issue with pymobiledevice3 (I've not tested it yet, so I can't confirm): https://github.com/tihmstar/usbmuxd2/issues/41 & https://github.com/doronz88/pymobiledevice3/issues/1147
https://github.com/tihmstar/usbmuxd2
This project doesn't get updates in 2 years. I think it is abandoned.
So back to my original question: how to make full device backup over network (no USB) as a regular Linux user?
I want to connect to a list of iOS devices at night in my local network, request an incremental encrypted backup and store it in the NAS at home. Exactly as iCloud backup operates, but with my own servers, own network and own storage. I don't mind pairing the devices with a cable as long as I can do it solely over the network afterwards.
There is no complete documentation that explains how to setup such backup environment on Linux (Fedora). I'm an experienced user, I've read and tried what's available, but didn't have success.
Can somebody please write such a complete guide ?
Thank you in advance
I might have made it work to some extent at least. But i have tried so much different things i am not fully sure what i actually did to make it work anymore...
But the commands that seem to work to make a full wireless backup of my iphone 18,3,2 iphone 12:
I make a tunnel with this command (for now at least, seems like screen needs to be on while i do this) : (pmdev3) sudo /home/palchrb/venvs/pmdev3/bin/pymobiledevice3 remote start-tunnel -t wifi -p tcp 2025-04-25 11:39:45 raspberrypi pymobiledevice3.cli.remote[123369] INFO tunnel created Identifier:XXXXX Interface: tun0 Protocol: TunnelProtocol.TCP RSD Address: fd60:cb84:1a5::1 RSD Port: 54915 Use the follow connection option: --rsd fd60:cb84:1a5::1 54915
And then i initiate the backup like so with your screen open: (pmdev3) palchrb@raspberrypi:~ $ pymobiledevice3 backup2 backup --rsd fd60:cb84:1a5::1 54915 ~/backuptest -v --full
The iphone asks for your password and then it starts. Since i am no expert in linux i cannot actually get the pymobiledevice3 usbmux list to work properly here, but the backup still runs like this... Probably not the ideal solution, but posting if this is helpful for some!
Edit: seems like its not using the usbmuxd at all, actually
If anybody knows how i could run this without having to input the password on my iphone so it could run in the background, then please let me know how!
@palchrb Sadly it's not possible without entering a code. It's a security feature by Apple - no way to get around it.
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
Hey buddy, I have a question for you. I feel like you're one of the few who actually knows how to do this.
My iOS device and my computer are on the same network, but for some reason, I want to create a tunnel to the iOS device using its IP and pairing files (essentially connecting via WiFi through the IP).
Do you know the basic code flow for this? I've been researching for a while, and no one seems to be able to answer. I'm really stuck.
I've found a method that supports network backup on Linux, tested on iOS 17.4.1 and iOS 18.3 with pymobiledevice3 4.27.0:
- Use the usbmuxd program compiled from https://github.com/tihmstar/usbmuxd2 and run it in USB-only mode: ./usbmuxd --no-wifi
- Connect your iOS device to the USB port
- Generate a pairing file: pymobiledevice3 lockdown pair
- Enable wireless support on the iOS device: pymobiledevice3 lockdown wifi-connections on
- Unplug the iOS device and stop usbmuxd
- Enable Wi-Fi on usbmux2: ./usbmuxd
- Enable tunneld: pymobiledevice3 remote tunneld. Keep the iOS device screen on. After a while, you should see a message indicating that a network RSD device has been found.
- You can now access the iOS device over the network: pymobiledevice3 lockdown info --rsd fd29:4998:c39::1 61328
- Start backup: pymobiledevice3 backup2 backup --rsd fd29:4998:c39::1 61328 iphone_backup
FYI, I found that the 6th step is not required for iOS 17.4.1 devices.
Excellent! Will try this latter.
Questions:
- Use the usbmuxd program compiled from https://github.com/tihmstar/usbmuxd2 and run it in USB-only mode: ./usbmuxd --no-wifi
Did you apply any specific patch to make this procedure work? Or probably the usbmuxd from my linux distribution will work too?
Which linux user you tested this peocedure? Works with regular user? Or has to be root?
Thank you in advance
Excellent! Will try this latter.
Questions:
- Use the usbmuxd program compiled from https://github.com/tihmstar/usbmuxd2 and run it in USB-only mode: ./usbmuxd --no-wifi
Did you apply any specific patch to make this procedure work? Or probably the usbmuxd from my linux distribution will work too?
Which linux user you tested this peocedure? Works with regular user? Or has to be root?
Thank you in advance
As I mentioned above, if it is ios18, then usbmuxd2 must be used. If it is ios17, you can use the original version of usbmuxd. I don't know the specific reason, but that's my test result. Although I use a root user, it should be fine if it is not root.
OK guys, I'm moving to 100% satisfying solution with libimobiledevice, which is packaged in most Linux distributions, and Jackson Coxson's netmuxd. Netmuxd complements usbmuxd with network capabilities and both must run together.
Netmuxd was not available in my platform package set, and OpenSSL needs a little tweeking, so a preparation script is required. Here are the steps to prepare my Fedora 42 and successfully backup my iPhone over the network. Nothing has to be done as root, all scripts and commands executed by my regular user.
Prepare things
This script will discover latest version of netmuxd for my platform and download it, and will prepare a configuration file for OpenSSL, so pairing won't fail.
#!/bin/sh
folder=/media/Backup/MobileSync
netmuxd=netmuxd-x86_64-linux-gnu
echo "Preparing compatible OpenSSL configuration"
# From https://github.com/libimobiledevice/libimobiledevice/issues/1606#issuecomment-2543116644
cat <<EOF > "$folder/openssl-weak.conf"
.include /etc/ssl/openssl.cnf
[openssl_init]
alg_section = evp_properties
[evp_properties]
rh-allow-sha1-signatures = yes
EOF
echo "Getting netmuxd binary..."
latest_netmuxd=`wget -q -O - https://api.github.com/repos/jkcoxson/netmuxd/releases/latest | jq -r '.assets[].browser_download_url' | grep $netmuxd`
wget -q $latest_netmuxd -O "$folder/$netmuxd"
chmod a+x "$folder/$netmuxd"
First pair device with a USB cable
We'll use the OpenSSL configuration file created above
OPENSSL_CONF=/media/Backup/MobileSync/openssl-weak.conf idevicepair pair
This creates some required signatures in /var/lib/lockdown/{device_UDID}.plist
Make backup
This method assumes usbmuxd is also running in your system, which is the regular setup for most Linux distros. Other methods are documented in netmuxd home page.
This script runs netmuxd, waits a bit until it finds my device in the network and then use idevicebackup2 to make the backup. A folder named with my device's UDID will be created under $folder (if it doesn't exists).
Since backup is mostly controlled by the device, this method also works for incremental backups even if the backup folder already has a backup created by Apple official software.
Your device will ask for your pin and then start backup.
#!/bin/sh
folder=/media/Backup/MobileSync
netmuxd=netmuxd-x86_64-linux-gnu
"$folder/$netmuxd" --disable-unix --host 127.0.0.1 &
pid=$!
# Wait a little bit until netmuxd finds device
sleep 15
# Start (incremental) backup
USBMUXD_SOCKET_ADDRESS=127.0.0.1:27015 OPENSSL_CONF="$folder/openssl-weak.conf" idevicebackup2 backup -n --full "$folder"
kill $pid
You might need to change these scripts a bit if you have multiple devices to backup.
iOS backup over the network takes a long time, like 20 minutes for an incremental backup, but is pretty solid and stable and I can use my device while roaming through multiple WiFi APs at home.
I put these scripts in the repo: https://github.com/avibrazil/iLinuxNetworkBackup