We are using App Engine, Datastore, and Java and we have been trying unsuccessfully to copy our production Google Datastore to a local copy.
(The full migration script I'm using is detailed in a separate Github question)
We use the following to export
gcloud datastore export --namespaces="(default)" gs://$GOOGLE_CLOUD_BUCKET
And then import that looks something like this
'http://' + $LOCAL_DATASTORE_HOSTNAME + ':' + $LOCAL_DATASTORE_PORT + '/v1/projects/' + $PROJECT_ID + ':import'
Running the script creates a "local_db.bin" which appears to be correct however then we copy it into the required location and run it we hit the following error.
com.google.appengine.api.datastore.dev.LocalDatastoreService init INFO: Local Datastore initialized: Type: High Replication Storage: \WEB-INF\appengine-generated\local_db.bin com.google.appengine.api.datastore.dev.LocalDatastoreService load INFO: Failed to load from the backing store, \WEB-INF\appengine-generated\local_db.bin java.lang.ClassNotFoundException: com.google.cloud.datastore.emulator.impl.LocalDatastoreFileStub$FileProfile at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
If we then save a new record it blows away the local_db.bin and creates a new one.
Anyone know where in the process this issue might be?
UPDATE:
I've followed the exact process that @Chris Halcrow describes in his answer, to re-import the data. The data is now successfully imported directly into the local_db.bin that App Engine should be seeing, however I still see the error.
We suspect there could be a permissions issue. We've tried changing some of the IAM permission for the account that AppEngine is running under. Specifically, we've tried adding the Project Editor IAM role to the account that we're using for our gcloud login
, as documented in activate DataStore permissions for App Engine.
We've also reviewed the following, which details required permissions when we're using the export/import Powershell script detailed in our GitHub question.
https://cloud.google.com/datastore/docs/export-import-entities#permissions
We believe our current roles should be allowing the required permissions that this describes.
Don't copy the local_db.bin file as this is likely to result in incorrect memory references/pointers. Follow the following procedure instead:
C:\my_app_engine_app\target\my-app-name-1.0-SNAPSHOT\WEB-INF\appengine-generated\local_db.bin
)appengine-generated
foldercd
to the directory that contains your AppEngine appdata-dir
specifies the directory you determined in step 3) -gcloud beta emulators datastore start --data-dir=C:\my_app_engine_app\target\my-app-name-1.0-SNAPSHOT\
(see https://cloud.google.com/datastore/docs/tools/datastore-emulator#starting_the_emulator)$LOCAL_DATASTORE_PORT
C:\my_app_engine_app\target\my-app-name-1.0-SNAPSHOT\WEB-INF\appengine-generated\local_db.bin
- you should see that it has inflated to indicate that it now contains your data.