WatermelonDB icon indicating copy to clipboard operation
WatermelonDB copied to clipboard

iOS Sqlite DB Backup and Restore

Open heyalexchoi opened this issue 2 years ago • 20 comments

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!

Related

https://github.com/Nozbe/WatermelonDB/issues/1012

heyalexchoi avatar Sep 12 '22 15:09 heyalexchoi

I think that we should add also android part

alicja-mruk avatar Sep 12 '22 15:09 alicja-mruk

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?

heyalexchoi avatar Sep 18 '22 17:09 heyalexchoi

no, at first glance, your code should work fine cross-platform 🎉

radex avatar Sep 21 '22 10:09 radex

is this pr going to be merged, any update?

batuhansahan avatar Oct 26 '22 10:10 batuhansahan

I confirm that it works on android

mlecoq avatar Jan 17 '23 16:01 mlecoq

@radex what is the best way to get this merged? aside from resolving conflicts.

heyalexchoi avatar Feb 01 '23 20:02 heyalexchoi

Any updates?

17Amir17 avatar Apr 27 '23 13:04 17Amir17

Could we get this merged please?

JoL0712 avatar May 01 '23 20:05 JoL0712

+1

smisaacs avatar Jun 22 '23 10:06 smisaacs

+1 really need this feature

KirillPirinen avatar Jun 30 '23 14:06 KirillPirinen

@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?

  1. How to backup the database
  2. How to read the backup into an existing database

Plus, is there a way to only save certain tables?

Stophface avatar Aug 29 '23 05:08 Stophface

Any update on this?

suchoX avatar Feb 26 '24 20:02 suchoX

@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 avatar Mar 07 '24 20:03 heyalexchoi

@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?

  1. How to backup the database
  2. 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.

heyalexchoi avatar Mar 07 '24 20:03 heyalexchoi

Can confirm it works, using this for a while <3

denissdubinin avatar Mar 08 '24 07:03 denissdubinin

Hello @radex, would you mind taking a look at this? It would be a great addition to WatermelonDB. Thank you!

ademarsj avatar Mar 24 '24 14:03 ademarsj