Best practices for core data store (sqlite) backup?

痴心易碎 提交于 2019-12-03 14:12:45

问题


I am working on an update for my new iphone app which will include the ability to back up & restore the Core Data store (SQLite). I have been looking for good options for how to do this but there are very few resources about this. What are the best practices that you have found for doing Core Data backup? I'd like to keep the configuration as simple as possible so that users actually back up. As we know, users very rarely back up manually. I'd like it to be automated if possible.

What have you found to be best practices for Core Data store (SQLite) backup?


回答1:


If you just want to do a backup, copy the sqlite file to another location. If you are looking for something more complicated, please update your question with the specific requirements.

Update

What other sort of more complicated options are available? I haven't see anyone do much besides actually copying the sqlite file.

Everything. You can integrate with the DropBox API and copy the file there. You can push changes to a REST service on a server, you can build a connection to MobileMe and push a copy there, you can translate it to JSON and push it anywhere. You can fax it to someone.

You could even set up a multi-file backup strategy that goes back six months: hourly for 24 hours, daily for 7 days, weekly for 4 weeks and monthly forever.

How you back up is an implementation detail. Core Data is open enough that you can translate it into any format you want and push it anywhere you want. It all depends on how much effort you want to put into it and where do you want to go with it.



来源:https://stackoverflow.com/questions/3364240/best-practices-for-core-data-store-sqlite-backup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!