<< Google App Engine for Java的Performance性能问题 | 首页 | Google App Engine性能调优 - 页面性能优化 >>

Google App Engine for Java数据备份下载

It is possible to use python tool bulkloader.py to create datastore backup of GAE Java app.

You just have to set up remote_api by adding following lines to web.xml:

<?xml version="1.0" encoding="utf-8"?>
<web-app>
 
<!-- Add this to your web.xml to enable remote API on Java. -->
 
<servlet>
   
<servlet-name>remoteapi</servlet-name>
   
<servlet-class>
com.google.apphosting.utils.remoteapi.RemoteApiServlet
</servlet-class>
 
</servlet>
 
<servlet-mapping>
   
<servlet-name>remoteapi</servlet-name>
   
<url-pattern>/remote_api</url-pattern>
 
</servlet-mapping>
 
<security-constraint>
   
<web-resource-collection>
     
<web-resource-name>remoteapi</web-resource-name>
     
<url-pattern>/remote_api</url-pattern>
   
</web-resource-collection>
   
<auth-constraint>
     
<role-name>admin</role-name>
   
</auth-constraint>
 
</security-constraint>
</web-app>

After that you can use bulkloader.py with --dump to download backup

and with --restore to upload backup to datastore.

You can also use the --kind=... argument to download all entities of a specific kind:

bulkloader.py --dump --app_id=<app-id> --kind=<kind> --url=http://<appname>.appspot.com/remote_api --filename=<data-filename>

You can download and upload every entity of a kind in a format suitable for backup and restore, all without writing any additional code or configuration. To download all entities of all kinds, run the folowing command:

bulkloader.py --dump --app_id=<app-id> --url=http://<appname>.appspot.com/remote_api --filename=<data-filename>

Downloading Data from App Engine

To start a data download, run appcfg.py download_data with the appropriate arguments:

appcfg.py download_data --config_file=album_loader.py --filename=album_data_archive.csv --kind=Album <app-directory>

If you are using a Google Apps domain name and need appcfg.py to sign in using an account on that domain, you must specify the --auth_domain=... option, whose value is your domain name.

If the transfer is interrupted, you can resume the transfer from where it left off using the --db_filename=... and --result_db_filename=... arguments. These arguments are the names of the progress file and the results file created by the tool, which are either names you provided with the arguments when you started the transfer, or default names that include a timestamp. This assumes you have sqlite3 installed, and did not disable progress files with --db_filename=skip.

标签 : , ,



发表评论 发送引用通报