puppetlabs/puppetlabs-mysql — pull request #549 by stevesaliman (2014-08-01 14:52:07+00:00)
Title: Added support for backing up triggers and routines to the mysql::server:backup module

The mysqldump command issued by the module-generated mysqlbackup.sh script does not include triggers or routines when it does a file-per-database backup. This means that if users try to restore a database using one of theses backup files, they will not be restoring the full structure of their database, just the data, which can leave users with broken applications due to missing routines. I think that it is important to support triggers and routines in a backup, especially if users are only backing up selected database, in which case the triggers and routines will not get backed up anywhere else.

To resolve this issue, I’ve added support for 2 new ```mysql::server::backup``` parameters (```mysql::backup``` is marked as deprecated, so I didn’t modify it) . The first is called ```include_triggers``` and the second is called ```include_routines```. When these parameters are true, the appropriate options are added to the mysqldump command. These flags have no effect when we are doing a full backup to a single file, since the triggers and routines will be backed up with the information_schema.

The default value for both new options is true, reflecting my belief that omitting triggers and routines is an oversight and not a feature. If you agree, this pull request is ready to go.

If, on the other hand, you feel that including triggers and routines should be an opt-in choice instead of default behavior, you’ll need to change the defaults in the module and fix some unit tests accordingly.

Either way, I think the ability to support the backup of triggers and routines in a file-per-database mode is important because it is the only way for users to generate a backup file for a single database that can be used to fully restore a single named database to its original state.