fcDbBackupPlugin - 0.1.1
This plugin adds a CLI task that performs automatic snapshots of your DB, and provides archiving capabilities.
You are currently browsing
the website for symfony 1
This plugin adds a CLI task that performs as many snapshots as you like, stores them in a configurable directory with a clear and readable naming structure, and offers auto-archiving capabilities inspired by Apple's Time Machine.
|Cedric Sadai||lead||moc.ycnega-bewdees <<ta>> cirdec|
Copyright (c) 2010 Cedric Sadai
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The fcDbBackupPlugin adds a CLI task that performs as many snapshots as you like, stores them in a configurable directory with a clear and readable naming structure, and offers auto-archiving capabilities inspired by Apple Time Machine.
Install the plugin (via a package)
symfony plugin:install fcDbBackupPlugin
Clear you cache (version prior to 1.3)
Configure the path you want to store your backups in, and the path to your RDBMS executables (latter is optional)
all: fcDbBackupPlugin: path: /your/backup/path/ pathToExec: /Applications/MAMP/Library/bin/ # path to your RDBMS executable files (optional)
Note: You can put or omit the ending slash, as the task is smart enough to deal with or without it. Also, it should also work with Windows-based paths.
Making a backup is as simple as calling the following task:
This plugin is ORM-agnostic, so it works both for Propel or Doctrine
You can perform as many snapshot per day as you like. Each file name will be automatically incremented with their version.
At runtime, the cleaning feature is called. It preserves all backups from the current and the previous month. Before that:
By default, the current active database will be saved. You need to have a database configured in the file "database.yml" for the backup utility to work.
Warning: For the moment, only MySQL is supported. PgSql is coded but has not been tested, other RDBMS to come soon.
If you want to call it from an outside task, just call it that way:
<?php //-- Backup of the database $dbsafe = new fcDbBackupTask($this->dispatcher, $this->formatter); $dbsafe->run(array(), array());
It is recommended to make this backup a running task, using the crontab utility on Linux for instance.
(after typing "crontab -e") 50 * * * * /path/to/php/php /path/to/symfony/project/symfony fc:dbBackup > /www/apache/logs/error_log
In this case the task will launched every hour, at *:50.
Make it compatible with more RDBMS
Automatic syncing with distant storage systems (like Amazon S3)
Both the name of the plugin and its logo refer to FatCap, the website for which it was originally developed.