You will find plenty of tutorials how to do the opposite. But here is how to use you iDevice as backup drive for times when you have no TimeMachine or other way to backup you Mac locally.
brew tap jlhonora/lsusb brew install lsusb brew tap osxfuse/osxfuse brew install osxfuse brew tap Homebrew/homebrew-fuse brew install ifuse
lsusband note the serial number of you connected iPad/iPhone
- create a mountpoint like
ifuse ~/stuff/ -u YOUR-SERIAL-HERE
- only if you have issues running
ifuse. You can try this:
brew uninstall --ignore-dependencies libtool brew uninstall --ignore-dependencies libimobiledevice brew uninstall ifuse brew install --HEAD libtool brew install --HEAD libimobiledevice brew install --HEAD ifuse
Now create a self resizing disk image on your device like so:
- open Disk Utility; press ⌘N
- choose the place on the mounted iDevice, e.g. ~/stuff/Documents
- name it; e.g. “backup”
- set the size to the max. you want; e.g. “200gb”
- pick Mac OS Extended or APFS
- pick 256-bit encryption and set a decent password
- pick Single GUID Partition
- pick “sparse bundle disk image”
Now you can mount this image by clicking it and store you backups manually by copying them over. But you can use
rsync which is a magical tool to make incremental backups and come preinstalled on macOS. The following will copy all files in you ~/back-this-up folder to the mounted backup image. The first time you do this it will take longer, but after that it will only copy what is missing or has changed!
rsync -av ~/back-this-up/ /Volumes/backup
And so you don’t have to type all this over and over again, I made this little batch script to mount, sync and unmount. So you can simply unplug you device once its done syncing.
#!/bin/bash mkdir ~/stuff ifuse ~/stuff/ -u YOUR-DEVICE-SERIAL echo iDevice is mounted hdiutil attach ~/stuff/Documents/backup.sparseimage echo Backup image mounted rsync -av ~/back-this-up/ /Volumes/backup echo Rsync done hdiutil detach /Volumes/backup umount -f ~/stuff rm -r ~/stuff echo -e "\033[1;32m Backup done! \033[0m"
Modify this to your needs and save as plaintext file called
backup into your user directory. Then call this to make it a executable shellscript:
chmod 700 ~/backup
Now, whenever you want backup your stuff you can run the backup file (ctrl click>open with>terminal) or just type
~/backup and the whole process runs automatically!