cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to backup files stored in Dropbox when using Sync API?

How to backup files stored in Dropbox when using Sync API?

Brendan D.
Explorer | Level 4

I have the requirement to allow the user to be able to backup all of their files. I have 3 locations I store files in my app. One is to store the files locally on the device. Second is to store the files in iCloud Drive in the Mobile Documents folder (which is just another folder in the file system), and third, in Dropbox.

In the local and iCloud Drive situations, I can simply create a zip file that stores all of the files to be backed up.

How would I go about doing that with Dropbox since there's no way of using regular NSFileManager calls on any files in Dropbox with the Sync API? Does it mean that every file I want to add to my zip file I have to first open a DBFile, read it into an NSData, then write it out to the local file system, then add that file to my zip archive? I can imagine that will perform very badly. Also, my directory structure can contain any number of folders and sub-folders. So this presents a bit of a problem for me I think when using the Sync API.

Do you have any recommendations on how to handle this situation?

2 Replies 2

Steve M.
Dropbox Staff

Yes, you'd need to open each file (to download it or access a cached copy), and then add each to your zip file individually.

I think the difference that's surprising you as compared to iCloud Drive (from your description) is that the Sync API doesn't proactively maintain local copies of files in Dropbox. It does cache them once they're accessed (on a MRU basis), in which case accessing the file should be quite fast. If the files aren't already in the local cache, though, it will take time to download them.

Brendan D.
Explorer | Level 4

Yes, I'm realizing that I'm going to have to just sync to a local cache of files so it operates a bit more like iCloud Drive. I was just trying to reduce the disk space required. But I think I can reduce the Dropbox cache size to accomplish that and still be able to access my files using NSFileManager calls, but interact with the Dropbox sync API for specific things, such as deleting files. It'll be much easier to make my backups then.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Brendan D. Explorer | Level 4
  • User avatar
    Steve M. Dropbox Staff
What do Dropbox user levels mean?