2.2
WordPress Database Backup: Quick Fix
20. August 2009 · Author: Dale Crum
4 Comments

WordPress Database Backup: Quick Fix

The WordPress Plugin: WordPress Database Backup by Austin Matzko is one of the more intuitive backup plugins currently available and with no stern warnings to scare off the faint of heart it has held its own as a very effective and useful tool. Recently though it has come to our attention that a small issue exists for some users of WordPress 2.8 – 1.9.1 wherein the navigation menu has simply disappeared. This applies to WP-DB-Backup Version 2.2.2. The plugin performs correctly if set prior to an upgrade with scheduled emails arriving on time but with no easy way to make changes or force a manual backup. It was decided that our Clients needed immediate access and so we have written a quick fix and provided a download until the issue is corrected by the author.

• Update: 1/14/10 The author has left a comment and updated the plugin for compatibility with 2.9.1 but issue of a missing settings page seems to still persist
Update: 6/11/10 Plugin Compatibility with 2.9.2. This quick fix is no longer needed, please use the download link to visit the original WP-DB-Backup WordPress page

Although the original issue at hand is a lack of management capabilities, we will be covering two modifications within this tutorial. The first alteration is Rediscovering and Relocating the navigational menu to a more suitable position under the Settings menu and the second alteration will be Granting Permissions to users other than the administrator.

Rediscover and Relocate:

In order to once again use the plugin’s settings page, we will relocate the menu by altering the current page_hook from “add_management_page” to one of the many other options available ( see Adding Administration Menus codex ) provided by WordPress for more information. For our purposes we will be moving it to the Settings sub menu by using “add_options_page”. Locate the “wp-db-backup.php” and look for the following line of code on line 593:

function admin_menu() {
$_page_hook = add_management_page(__('Backup','wp-db-backup'), __('Backup','wp-db-backup'), 'import', $this->basename, array(&$this, 'backup_menu'));
add_action('load-' . $_page_hook, array(&$this, 'admin_load'));
if ( function_exists('add_contextual_help') ) {
$text = $this->help_menu();
add_contextual_help($_page_hook, $text);
}
}

and alter it from “add_management_page” to “add_options_page” effectively moving it from the Edit sub menu to the Settings sub menu which helps to keep the menu structure clean and organized.

function admin_menu() {
$_page_hook = add_options_page(__('Backup','wp-db-backup'), __('Backup','wp-db-backup'), '1', $this->basename, array(&$this, 'backup_menu'));
add_action('load-' . $_page_hook, array(&$this, 'admin_load'));
if ( function_exists('add_contextual_help') ) {
$text = $this->help_menu();
add_contextual_help($_page_hook, $text);
}
}

To complete the move locate this next line of code starting on line 601:

function fragment_menu() {
$page_hook = add_management_page(__('Backup','wp-db-backup'), __('Backup','wp-db-backup'), 'import', $this->basename, array(&$this, 'build_backup_script'));
add_action('load-' . $page_hook, array(&$this, 'admin_load'));
}

and again alter it from “add_management_page” to “add_options_page”.

function fragment_menu() {
$page_hook = add_options_page(__('Backup','wp-db-backup'), __('Backup','wp-db-backup'), 'import', $this->basename, array(&$this, 'build_backup_script'));
add_action('load-' . $page_hook, array(&$this, 'admin_load'));
}

This completes the Rediscovery and Relocation and at this point it is not necessary to move forward with the next step for Administrative access only. Because we needed to grant permissions to the Backup option for all users other than subscribers, we will demonstrate this as well.

Grant Permissions:

In order to grant usage permissions, WordPress provides a very intuitive and useful sliding scale ranging from 1 to 10 as well as a myriad of other capabilities specific to a user level to determine the access level of a particular user. For further information on this subject please see the Roles and Capabilities codex provided by WordPress.

Currently WordPress Database Backup utilizes the “import” role granting access by the site administrator only. We will be making a minor alteration to grant all but subscribers access by using “level_1″. Locate the following function starting on line 592:

function admin_menu() {
$_page_hook = add_management_page(__('Backup','wp-db-backup'), __('Backup','wp-db-backup'), 'import',

and alter “import” to “level_1″.

function admin_menu() {
$_page_hook = add_options_page(__('Backup','wp-db-backup'), __('Backup','wp-db-backup'), 'level_1',

Next locate the following function starting on line 601:

function fragment_menu() {
$page_hook = add_management_page(__('Backup','wp-db-backup'), __('Backup','wp-db-backup'), 'import',

and again alter “import” to “level_1″.

function fragment_menu() {
$page_hook = add_management_page(__('Backup','wp-db-backup'), __('Backup','wp-db-backup'), 'level_1',

To complete the user access permissions locate the following on line 1389:

if ( ( $this->wp_secure('fatal', $loc) ) && current_user_can('import') )
$can = $this->verify_nonce($_REQUEST['_wpnonce'], $this->referer_check_key, $loc);

and alter “import” to “level_1″.

if ( ( $this->wp_secure('fatal', $loc) ) && current_user_can('level_1') )
$can = $this->verify_nonce($_REQUEST['_wpnonce'], $this->referer_check_key, $loc);

Please note that any role or capability access can be used. We hope this has been a helpful tutorial and has at least permitted access to the plugin once again.

Installation

  1. Download the plugin and expand it.
  2. Copy the d4-backup folder into your plugins folder ( wp-content/plugins ).
  3. Log-in to the WordPress administration panel and visit the Plugins page.
  4. Locate the d4-backup plugin and click on the activate link.
  5. The plugin will attempt to create a directory titled /wp-content/backup-*/ within your WordPress directory.
  6. It may be necessary to make the "wp-content" folder writable to create this directory.

4 Comments

  1. David Thornton,

    Have you set up a “backup” folder in the wp-contents root and given this folder 777 permissions as per the setup requirements? What version of WordPress are you currently running and are you backing up to your desktop or sending through an email account?

  2. I am trying to back up my wordpress files using plug in 2.2.2 and get this message: File not found: ftmqzxz_wrdp4_wp_20100311_879.sql.gz This is on site http://talkingwristbloodpressuremonitor.com. I also tried on several of my other sites and get same message (except wrdp number is different for different sites. What am I doing wrong, and how can it be fixed. Any help will be apopreciated. Regards, David

  3. Could you explain why you would want to modify my plugin to allow those without admin rights to download copies of the database? Sounds like a security risk to me.

  4. Austin,

    I agree that it is a security risk used in the wrong situation i.e. Subscribers, Authors, etc. This is a situation where WordPress is used as a content management system for a website that is managed by a single user. This particular user has requested that we handle updates to the website while they maintain updates and regular backups due the type of website and the visitors involved. What we have done is limit the client’s admin options while allowing them to maintain a backup of their site when they deem it necessary. Keep in mind that WordPress is not always used as in community situation and therefore this particular modification may come in handy to some.

Leave A Comment

Please wrap any code within the <code> tag to display properly

I've been thinking a lot lately about stability versus spontaneity, freedom versus structure. Sometimes I find myself saying things like, "You can't grow unless you try new things,...

As I sit here at my desk with yet another article deadline staring me in the face, I can't help but wonder if I'm the only one who is plagued by the appealing face of procrastination....

In the advertising business we all aspire to do something big, something memorable, something great that has never been done before; unfortunately not very many of us get the opportunity...

I am under the personal belief that post titles should be short, sweet and precise enough to get the point across without sounding like an awkward newspaper headline. Sadly not all...

If you're involved in the world of design, whether it is by trade or business necessity, then you are probably familiar with the term "spec design", also known as "crowdsourcing". The...