realm-java icon indicating copy to clipboard operation
realm-java copied to clipboard

How to export realm database backup file in android?

Open koz01 opened this issue 10 years ago • 14 comments

I

koz01 avatar May 23 '16 07:05 koz01

Hi @koz01 Not sure what you are asking? A Realm database is just a file you can backup any way you want. You can use RealmConfiguration.getPath() to get the actual location of the file.

cmelchior avatar May 23 '16 07:05 cmelchior

@koz01 Can https://medium.com/glucosio-project/example-class-to-export-import-a-realm-database-on-android-c429ade2b4ed#.kogne3ocy help you?

kneth avatar May 23 '16 14:05 kneth

@kneth That is just our workaround and its not ideal even for Glucosio as a project for instance its difficult for us to be able to offer export to XLS or PDF or even import CSV or XLS (We cannot currently import anything except .realm files into our app)

Other mobile db's officially offer this support and so do server side db's so unsure why this is not a priority.

@cmelchior ^

ghost avatar May 25 '16 18:05 ghost

Import support exists for swift but for java there is a feature parity gap in Realm http://stackoverflow.com/questions/34362618/import-data-to-realm-database

ghost avatar May 25 '16 18:05 ghost

@bkerensa Yes, we do want to add support for importing/exporting data but currently we are prioritising other features. In general we try to fix the issues that doesn't have work-arounds first, and it should be entirely possible to import/export data from CSV using our existing API's.

cmelchior avatar May 25 '16 19:05 cmelchior

I'm closing the issue. Importing and exporting data are nice features, and we currently track them in #2880.

kneth avatar May 30 '16 08:05 kneth

Whenever I want to analyse a realm file, and I copy the realm file + realm.lock file, to the device, I get an Invalid format of Realm file exception? Any ideas how I can look at the realm file, on a device?

JohnnyTwoShoes avatar Jan 25 '17 10:01 JohnnyTwoShoes

You shouldn't copy the lock file, just the realm file.

cmelchior avatar Jan 25 '17 10:01 cmelchior

Are you using https://realm.io/docs/java/latest/api/io/realm/Realm.html#writeCopyTo-java.io.File-?

Zhuinden avatar Jan 25 '17 11:01 Zhuinden

I'm copying the files onto the device, using adb push If there is an old lock file, on the device, should I delete it ( if I'm not going to adb push a lock file onto the device, but, I am going to push the realm file)?

JohnnyTwoShoes avatar Jan 25 '17 11:01 JohnnyTwoShoes

The lock file is there for controlling concurrent access to the Realm file when it is opened, but it also tied to the particular architecture, .e.g you cannot use a lock file from 64 bit system on a 32 bit system.

I believe you don't have to delete it even if you override the Realm file, but doing so will definitely not hurt.

cmelchior avatar Jan 25 '17 11:01 cmelchior

ok, thanks, then the issue must be with something else, since, without the lock file, I'm still getting the same error (Invalid format of Realm file).

JohnnyTwoShoes avatar Jan 25 '17 13:01 JohnnyTwoShoes

@JohnnyTwoShoes Can you verify that the file has not been truncated (just check the size with adb shell ls -l)? Is the file encrypted? If so, does the key match?

kneth avatar Jan 27 '17 15:01 kneth

Hi Guys.

I'm using this bash file.

https://gist.github.com/mMarcos208/033e56a4cc0f5f256ef64359598ab904

mMarcos208 avatar May 06 '22 15:05 mMarcos208