Automatically back up to Google Cloud storage - Google App Engine datastore using cron.yaml

So, I'm trying to automate our backups of the GAE data warehouse using cron.yaml. In addition, I would like to use Google Cloud Storage as the destination for our backups. I created a bucket and configured the ACL. Manual backups work from the data warehouse administrator console. I can even get cron to work. But we are pushing the same code base to three different environments: dev, staging, production. Therefore, I would like to split the backups in different codes based on the name of the application.

I would like intermediate storage to move to myapp_staging_bk bucket, dev to myapp_dev_bk bucket and exit to myapp_live_bk.

cron.yaml:

    cron:
- description: My Daily Backup
  url: /_ah/datastore_admin/backup.create?name=BackupToCloud&kind=LogTitle&kind=EventLog&filesystem=gs&gs_bucket_name=whitsend
  schedule: every 12 hours
  target: ah-builtin-python-bundle

All of this would be very simple if I could find a way to pull out the application name in the above URL. Something like that:

url: /_ah/datastore_admin/backup.create?name=BackupToCloud&kind=LogTitle&kind=EventLog&filesystem=gs&{myapp}_bk=whitsend
  schedule: every 12 hours

where {myapp} will be the name of the application that is in app.yaml.

https://developers.google.com/appengine/articles/scheduled_backups does not say anything about this type of installation.

I know that I could remove this from our CI server, but I would like to avoid this.

Does anyone have any suggestions?

+5
source share
2 answers

Change the cron handler to call your own code, then either call the code to start the backup from your own code, or URLFetch it from your own code after filling in the bucket name parameter based on your application ID.

+3
source

, , API- Taskqueue . , cron .

. python:

task = taskqueue.add(
    url='/_ah/datastore_admin/backup.create',
    target='ah-builtin-python-bundle',
    params={
        'name': 'my_backup',
        'kind': ['kind1','kind2','kind3'],
        'filesystem':'gs',
        'gs_bucket_name':'[MY_GCS_BUCKET]',
    })

response.write(
    'Task {} enqueued, ETA {}.'.format(task.name, task.eta))
0

All Articles