Backing Up WhatsApp Media From iCloud
Every so often I like to copy all of the WhatsApp media from my iPhone/iCloud to my Mac. This is sadly much trickier than it should be.
Every few months, I like to copy over all of the images, GIFs and videos from my iPhone WhatsApp to my Mac. It turns out this is much harder than it should be due to the nuances of iCloud.
Your WhatsApp backups aren't easily accessible in iCloud. If you check the settings you'll see your backups but you can't do anything with them:
That said, they are available, just not via Finder or the iCloud Drive interface. So how can we get acess to them?
I asked this question on StackExchange where user @Kanthala Raghu gave me a great answer on how to go about it, so here's an updated summary for a task I return to again and again.
Why bother grabing WhatsApp backups in the first place?
I actually have a convoluted process of archiving it all into folders automatically via Hazel that I'll cover in another post. But essentially I just want a browseable backup of stuff from WhatsApp.
Configure WhatsApp to Backup to iCloud
The first thing you need to do is ensure that you are backing up your WhatsApp media to iCloud in the first place.
Go to your WhatsApp app, then Settings
> Chats
> Chat Backup
. It should look like this:
Note that encryption is set to off. I haven't confirmed, but I assume you can't have encryption on and continue to access your data via iCloud.
Find iCloud Location on Mac
You now need to find where your WhatsApp backups are located on your Mac. For me the folder looks likes:
cd ~/Library/Mobile Documents/57T9237FN3~net~whatsapp~WhatsApp/Accounts/447931423667/backup
If you look at the contents of this folder it should look like:
> tree -L 1 -a
.
├── .BackedUpKeyValue.sqlite.enc.icloud
├── .Backup.plist.icloud
├── .CallHistory.sqlite.enc.icloud
├── .ChatStorage.sqlite.enc.icloud
├── .Document.tar.icloud
├── .GIFs.tar.icloud
├── .LID.sqlite.enc.icloud
├── .Media.tar.icloud
├── .Media_1.tar.icloud
├── .Sticker.sqlite.enc.icloud
├── .Stickers.tar.icloud
├── .Thumbnail.tar.icloud
├── .Thumbnail_1.tar.icloud
├── .UserDefaults.plist.enc.icloud
├── .Video.tar.icloud
├── .current_wallpaper.jpg.enc.icloud
└── .current_wallpaper_dark.jpg.enc.icloud
1 directory, 17 files
Notice that we have a load of .icloud
files here. This are iCloud placeholder files, meaning they aren't stored
locally on the machine and therefore need to be downloaded from iCloud.
The ones I'm interested in are:
Media.tar.icloud
Media_1.tar.icloud
GIFs.tar.icloud
Video.tar.icloud
In order to download these files we can use the brctl
. This is a relatively undocumented command supplied by
Apple to interact with iCloud. The download
command will pull files down from iCloud to your local machine.
You can go one-by-one:
brctl download Media.tar
brctl download Media_1.tar
brctl download Video.tar
brctl download GIFs.tar
// ...
or you can use this one-liner:
find . -name *.icloud -exec brctl download {} \; -print
Note that you exclude the leading .
and the trailing .icloud
. This will
start the download in the background.
Now it's time to wait for the files to download. This can take a while without any apparent progress. You can check status with:
brctl log -w --shorten
and
brctl monitor
These logs aren't very clear, but if things are happening in the logs, it probably means there are some files still downloading.
Copy the files
Once downloaded, you should see the .icloud
files replaced with .tar
archives. You can then copy these out somewhere else:
For example:
cp -rf GIFs.tar Media.tar Media_1.tar Video.tar Video_1.tar ~/
Where you go from here is your business. As mentioned above, I use Hazel to do some autosorting of these files into an archive, which I'll cover at some point in the future.
Evict Files When Ready
To save space, you can evict your local copy of these files. Instead of the download
command, we use the evict
command:
brctl evict Media.tar
brctl evict Media_1.tar
brctl evict Video.tar
brctl evict Video_1.tar
brctl evict GIFs.tar
Here's a script to do the whole folder:
find . -not -name "*.icloud" -exec brctl evict {} \; -print
Hurrah. You now have a folder full of useless memes and nonsense food pictures. Enjoy!