title: App Engine - LocalDatastoreService load - Failed to load from the backing store
body: <p>We are using App Engine, Datastore, and Java and we have been trying unsuccessfully to copy our production Google Datastore to a local copy.</p>
  
  <p>(The full migration script I'm using is detailed in a separate <strong><a href="https://github.com/googleapis/google-cloud-java/issues/4661" rel="nofollow noreferrer">Github question</a></strong>)</p>
  
  <p>We use the following to export</p>
  
  <pre><code>gcloud datastore export --namespaces="(default)" gs://$GOOGLE_CLOUD_BUCKET
  </code></pre>
  
  <p>And then import that looks something like this</p>
  
  <pre><code>'http://' + $LOCAL_DATASTORE_HOSTNAME + ':' + $LOCAL_DATASTORE_PORT + '/v1/projects/' + $PROJECT_ID + ':import'
  </code></pre>
  
  <p>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.</p>
  
  <blockquote>
    <p>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)</p>
  </blockquote>
  
  <p>If we then save a new record it blows away the local_db.bin and creates a new one.</p>
  
  <p>Anyone know where in the process this issue might be?</p>
  
  <h2>UPDATE:</h2>
  
  <p>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. </p>
  
  <p>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 <code>gcloud login</code>, as documented in <a href="https://cloud.google.com/datastore/docs/activate#datastore-permissions-for-app-engine" rel="nofollow noreferrer">activate DataStore permissions for App Engine</a>.</p>
  
  <p>We've also reviewed the following, which details required permissions when we're using the export/import Powershell script detailed in our GitHub question.</p>
  
  <p><a href="https://cloud.google.com/datastore/docs/export-import-entities#permissions" rel="nofollow noreferrer">https://cloud.google.com/datastore/docs/export-import-entities#permissions</a></p>
  
  <p>We believe our current roles should be allowing the required permissions that this describes.</p>