The Backup feature in the developer console for creating backups is great. I would however like the possibility to automate this. Is there a way to do so from the cf command line app?
Thanks
It's not possible from the cf cli
, but there's an API endpoint for triggering backups.
API Docs | Custom Extensions | Swisscom Application Cloud Filter for Cloud Foundry (CF) Cloud Controller (CC) API. Implements Swisscom proprietary extensions
POST /custom/service_instances/{service-instance-id}/backups
Creates a backup for a given service instance
See for more Info Service Backup and Restore in docs.developer.swisscom.com
Create Backup To create a backup, navigate to the service instance in the web console and then to the “Backups” tab. There you can click the “Create” button to trigger a manual backup.
Note: Backups have to be triggered manually from the web console.
Be aware that you can only keep a set number of backups per service instance. The actual number is dependent on the service type and service plan. In case you already have the maximum number, you cannot create any new backups before deleting one of the existing.
It may take several minutes to backup your service (depending on the size of your service instance).
Restore Backup You can restore any backup at any time. The current state of your backup will be overwritten and replaced with the state saved to the backup. You are advised to create a backup of the current state before restoring an old state.
Limitations You can only perform one backup or restore action per service instance at a time. If an action is still ongoing, you cannot trigger another one. You cannot exceed the maxmimum number of backups per service instance
We did this by developing a small Node.js application which is running on the cloud in the same space and which backups our maria and mongo db every night automatically.
EDIT: You can download the code from here: https://github.com/theonlyandone/cf-backup-app
Fresh from the press: Swisscom Application Cloud cf CLI Plugin can also automate backup and restore.
The official cf CLI plugin for the Swisscom Application Cloud gives you access to all the additional features of the App Cloud.
cf install-plugin -r CF-Community "Swisscom Application Cloud"
from 0.1.0 release notes
Service Instance Backups
- Add
cf backups
command (list all backups of a service instance)- Add
cf create-backup
command (create a new backup of a service instance)- Add
cf restore-backup
command (restore an existing backup of a service instance)- Add
cf delete-backup
command (delete an existing backup of a service instance)
Despite the answer from Matthias Winzeler saying it's not possible, in fact it's totally possible to automate MariaDB backups through the command line.
I developed a plugin for the CF CLI: https://github.com/gsmachado/cf-mariadb-backup-plugin
In future I could extend such plugin to backup any kind of service that is supported by the Cloud Foundry Provider's API (in this case, Swisscom AppCloud API).
来源:https://stackoverflow.com/questions/39655921/mariadb-backup-from-the-command-line