-
Notifications
You must be signed in to change notification settings - Fork 4
Backup event_log database content
Currently, DB records are deleted after a particular row limit set by the administrator, but no backup is created for these deleted logs. It would be useful if a backup in a file is created for these logs for future reference.
Also, if these backups are mailed to the administrator when required or when cron runs, would be a cherry on the cake.
This feature can be used in collaboration with the clear log messages button feature, i.e you might want to take a backup of the logs that you are about to clear.
Upstream link : https://www.drupal.org/node/2883592
This feature enables the administrator and privileged users to create a backup file that consists of current database records.
This can be done by enabling the Backup content sub-module in the modules section. Once the module is enabled, backup can be created and viewed by pressing the “View/Update and Save Backup Content” button.
The backup file is created at /sites/default/files folder. Every time the “View/Update and Save Backup Content” button is clicked, a new file named backup_#.txt is created where # is a suffixed incrementing integer starting from 0.
Moreover, the content of backup_#.txt file is mailed to the administrator.
Also, by checking the “Enable Backup Content in Cron Run” checkbox, the same set of actions are performed.
A new sub-module named event_log_backup is added in the event_log folder. The .module file implements the desired action using hook api functions namely, hook_menu, hook_cron, hook_mail and hook_permission.
Details about this functions can be found at :
hook_menu : To register paths to configuration page and associate a callback form function with it. https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_menu/7.x
hook_permission : To enable administrator to provide privileges to different users. https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_permission/7.x
hook_cron : Defines additional instructions to be executed when cron runs. https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_cron/7.x
hook_mail : Prepare a message based on parameters; called from drupal_mail(). https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_mail/7.x
Besides the above hook api functions, some user defined functions in the sub-module are:
event_log_backup_read : Queries the database to fetch the events and saves to backup_#.txt
event_log_backup_send : Mails the content of backup_#.txt using drupal_mail().
- Added Sub-Module does not appear in the same section as the event log.
- No configuration option corresponding to the added sub-module.
- Path to backup_#.txt in the event_log_backup module is not working.
- Add a package name and dependencies to your .info file so that your sub-module appears under the right section, which is statistics in the event_log module case.
E.g : package = Statistics
dependencies[] = event_log
- Add configure = admin/config/event_log_backup
- Change the path to public://backup_#.txt instead of specifying the complete path. By doing so, a file is automatically created at sites/default/files/ and no permission issues arise.
- Ability to log to a file instead of a database
- Backup event_log database content
- Clear log messages button
- Notify Illegal access to authorized user
- Log Data to Cloud (Experimental)