Search code examples
iosmacosicloudcloudkit

(iCloud) How to programmatically Backup/Restore data for all Apps like iTunes does?


I'd like to backup and restore files (or other type of informations like key-value, SQL-like transaction based info.) for NOT ONLY my app but also all the other Apps using iCloud.

I'm just new to iCloud and read only a few documents but it seems iCloud APIs are just for single App boundary (of course I understand there is an option for sharing information between 'Group' of applications).

What I want to do is backup and restore almost everything. How can I do that? (There some apps doing this like http://www.copytrans.net/copytranscontacts.php http://www.macrumors.com/2012/05/18/elcomsofts-phone-forensics-software-offers-near-real-time-access-to-icloud-backups/)

I checked that the some of the Mobile App files are stored inside the "~/Library/Application\ Support/MobileSync/Backup" directory but there are only some of the files from all the files actually stored in iCloud.

And I tested CloudKit, but it just takes control over App's own data only.

Thanks in advance.


Solution

  • One thing to keep in mind when thinking about this is that iTunes actually doesn't backup or restore anything to/from iCloud. iOS device does it on its own: there's a daemon process running and if iCloud Backup is enabled, it will backup directly to iCloud, without talking to iTunes. Restore is also done without interaction with iTunes.

    Next, as @rmaddy pointed out, your app on the device cannot access files of other apps, so you won't be able to do what you want from the device. If you want to do this via companion app running on PC/Mac then it might be possible, but will depend on what exactly do you need/want.

    Re: contacts. Apps can access AddressBook and thus can sync/upload its contents. Apps can also access some other shared data, such as Photo Library. This is still a far cry from your original request to "Backup/Restore data for all Apps".

    Re: downloading iCloud backups. Downloading isn't a big deal those days (Disclosure: I am the author of that forensic tool to download iCloud backups you're mentioned). There is even an open-source code for that. However, downloading and restoring are two very different processes. Specifically, you can download, but your app won't have enough permissions to write files in place.

    Hope this helps and clears things up.