diff --git a/iPhone-synchronization-linux.md b/iPhone-synchronization-linux.md new file mode 100644 index 0000000..1b49225 --- /dev/null +++ b/iPhone-synchronization-linux.md @@ -0,0 +1,111 @@ +# iPhone Synchronization under Arch Linux + +## Wired synchronization with libimobiledevice and ifuse + +### Installation + +``` +sudo pacman -S libimobiledevice ifuse +``` + +**Install the necessary tools:** On your Linux system, install libimobiledevice and ifuse. The installation command depends on your distribution (e.g., sudo apt-get install libimobiledevice-utils on Debian/Ubuntu or use the AUR for Arch-based systems). + +**Connect your iPhone:** Plug your iPhone into your computer with a USB cable. + +**Trust the computer:** On your iPhone, tap "Trust" when the prompt appears and enter your passcode. + Mount the device: Open a terminal and create a mount point, for example, mkdir ~/iPhone. Then, mount the device with the command ifuse ~/iPhone. + +**Access files:** Your iPhone should now appear as a mounted device, typically with a DCIM folder containing your photos and videos. You can browse and copy files from this folder to your computer. + +### Script to synchronize the iPhone data to the Linux PC + +Create a new file, e.g. `sync-iPhone.sh` with the content: + +``` +#!/bin/sh +program_list=("ifuse" "ldconfig" "rsync") +library_list=("libimobiledevice") +sync_folder="$HOME/iPhone" +sync_mount="${sync_folder}/.mnt" +sync_data="${sync_folder}/data" + +# iteration thru list of programs +for program in "${program_list[@]}" +do + if command -v "${program}" >/dev/null 2>&1 + then + echo "OK, ${program} exists." + else + echo "Sorry, ${program} does not exists," + echo "you have to install all of these programs first: ${program_list[@]}" + exit 1 + fi +done + +# iteration thru list of libraries +for library in "${library_list[@]}" +do + if ldconfig -p | grep ${library} >/dev/null 2>&1 + then + echo "OK, ${library} exists." + else + echo "Sorry, the library ${library} is not installed." + echo "You have to install the libraries first: ${library_list[@]}" + exit 2 + fi +done +echo "Create the folder ${sync_mount} ..." +if mkdir -p ${sync_mount} >/dev/null 2>&1 +then + echo "done." +else + echo "Folder ${sync_mount} already exists." +fi + +echo "Mount the iPhone into that folder using ifuse ..." +if ifuse ${sync_mount} +then + echo "ok." +else + echo "did not work. Check your connection to the iPhone." + exit 3 +fi + +echo "RSYNC the iPhone ..." +FROM="$sync_mount"/ +TO="$sync_data"/ + +while true +do + echo "** Synchronization from ${FROM} to ${TO} **" + read -n 1 -p"Sync iPhone and delete old files (y)es/(n)o/(c)ancel? " response + echo + case ${response} in + [Nn]* ) rsync -avP "${FROM}" "${TO}"; break;; + [YyJj]* ) rsync -avP --delete "${FROM}" "${TO}"; break;; + [Cc]* ) break;; + * ) echo "Please answer yes, no or cancel.";; + esac +done +echo "Memory usage on the iPhone:" && du -hs ${sync_mount} + +echo "Unmount the iPhone ..." +if umount ${sync_mount} +then + echo "done." +else + echo "The umounting procedure did not work." +fi +echo "Remove temporary mount point ..." +rmdir ${sync_mount} +echo "done." +echo "Disk usage:" && du -hs ${sync_folder} +``` +You have to set the executable flag to this file `sync-iPhone.sh` with +``` +chmod +x sync-iPhone.sh +``` +Now you can execute that script using +``` +./sync-iPhone.sh +``` \ No newline at end of file diff --git a/sync-iPhone.sh b/sync-iPhone.sh new file mode 100755 index 0000000..cc1b161 --- /dev/null +++ b/sync-iPhone.sh @@ -0,0 +1,78 @@ +#!/bin/sh +program_list=("ifuse" "ldconfig" "rsync") +library_list=("libimobiledevice") +sync_folder="$HOME/iPhone" +sync_mount="${sync_folder}/.mnt" +sync_data="${sync_folder}/data" + +# iteration thru list of programs +for program in "${program_list[@]}" +do + if command -v "${program}" >/dev/null 2>&1 + then + echo "OK, ${program} exists." + else + echo "Sorry, ${program} does not exists," + echo "you have to install all of these programs first: ${program_list[@]}" + exit 1 + fi +done + +# iteration thru list of libraries +for library in "${library_list[@]}" +do + if ldconfig -p | grep ${library} >/dev/null 2>&1 + then + echo "OK, ${library} exists." + else + echo "Sorry, the library ${library} is not installed." + echo "You have to install the libraries first: ${library_list[@]}" + exit 2 + fi +done +echo "Create the folder ${sync_mount} ..." +if mkdir -p ${sync_mount} >/dev/null 2>&1 +then + echo "done." +else + echo "Folder ${sync_mount} already exists." +fi + +echo "Mount the iPhone into that folder using ifuse ..." +if ifuse ${sync_mount} +then + echo "ok." +else + echo "did not work. Check your connection to the iPhone." + exit 3 +fi + +echo "RSYNC the iPhone ..." +FROM="$sync_mount"/ +TO="$sync_data"/ + +while true +do + echo "** Synchronization from ${FROM} to ${TO} **" + read -n 1 -p"Sync iPhone and delete old files (y)es/(n)o/(c)ancel? " response + echo + case ${response} in + [Nn]* ) rsync -avP "${FROM}" "${TO}"; break;; + [YyJj]* ) rsync -avP --delete "${FROM}" "${TO}"; break;; + [Cc]* ) break;; + * ) echo "Please answer yes, no or cancel.";; + esac +done +echo "Memory usage on the iPhone:" && du -hs ${sync_mount} + +echo "Unmount the iPhone ..." +if umount ${sync_mount} +then + echo "done." +else + echo "The umounting procedure did not work." +fi +echo "Remove temporary mount point ..." +rmdir ${sync_mount} +echo "done." +echo "Disk usage:" && du -hs ${sync_folder}