WatermelonDB
WatermelonDB copied to clipboard
iOS Sqlite DB Backup and Restore
Hey, just started using Watermelondb. Great work! I need to be able to backup and restore the db on iOS. Added the capability here. Did my best to follow guidelines and visible patterns. Please let me know if there's anything else I should do to help this get merged!
https://github.com/Nozbe/WatermelonDB/issues/1012
I think that we should add also android part
I'm adding this functionality for an app that does not yet have an android component. I'm looking at the native code I've written, and it looks like it is shared between platforms. Is there more needed to make this work for android as well?
no, at first glance, your code should work fine cross-platform 🎉
is this pr going to be merged, any update?
I confirm that it works on android
@radex what is the best way to get this merged? aside from resolving conflicts.
Any updates?
Could we get this merged please?
+1
+1 really need this feature
@heyalexchoi since this probably does not get merged and your changes are not that much, I am going to implement that in a fork of mine. CAn you give an example how you use this?
- How to backup the database
- How to read the backup into an existing database
Plus, is there a way to only save certain tables?
Any update on this?
@radex is this a feature you would be interested in accepting, if I rebase my branch, bringing it up to date and getting rid of the merge conflicts? Asking because I don't want to do that work unless you're interested in accepting.
@heyalexchoi since this probably does not get merged and your changes are not that much, I am going to implement that in a fork of mine. CAn you give an example how you use this?
- How to backup the database
- How to read the backup into an existing database
Plus, is there a way to only save certain tables?
Backup:
await getDatabase().writeToFile(filePath)
Restore:
await getDatabase().readFromFile(filePath)
This does not support saving certain tables. It only backs up and restores the sqlite db to and from file. It is a pretty efficient operation, probably more so than selecting data to export, so feel free to give it a shot for your use case.
Can confirm it works, using this for a while <3
Hello @radex, would you mind taking a look at this? It would be a great addition to WatermelonDB. Thank you!