Plugin Directory

Changeset 201698


Ignore:
Timestamp:
02/04/2010 06:02:24 AM (16 years ago)
Author:
DanCoulter
Message:

Updated the restore feature to allow database settings to be
overwritten.

Location:
automatic-wordpress-backup/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • automatic-wordpress-backup/trunk/S3.php

    r185398 r201698  
    894894        curl_setopt($curl, CURLOPT_WRITEFUNCTION, array(&$this, '__responseWriteCallback'));
    895895        curl_setopt($curl, CURLOPT_HEADERFUNCTION, array(&$this, '__responseHeaderCallback'));
    896         curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
     896        //curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    897897
    898898        // Request types
  • automatic-wordpress-backup/trunk/automatic-wordpress-backup.php

    r192499 r201698  
    22/*
    33Plugin Name: Automatic WordPress Backup
    4 Plugin URI: http://www.wordpressbackup.org/
     4Plugin URI: http://www.webdesigncompany.net/automatic-wordpress-backup/
    55Description: Automatically upload backups of important parts of your blog to Amazon S3
    6 Version: 1.1.0-dev6
     6Version: 1.1.0-dev7
    77Author: Dan Coulter
    88Author URI: http://dancoulter.com/
     
    4040
    4141class cmAWB {
    42     static $version = '1.1.0-dev6';
     42    static $version = '1.1.0-dev7';
    4343
    4444    /**
     
    182182           
    183183        }
    184        
    185         $fsd = new WP_Filesystem_Direct(1);
    186         //print_r($fsd->dirlist($fsd->wp_content_dir(), true, true));
    187        
    188 
    189        
     184
    190185        ?>
    191186            <script type="text/javascript">
     
    238233
    239234                <?php endif; ?>
    240                 <?php //self::backup(true) ?>
     235
    241236                <form method="post" action="options.php">
    242237                    <input type="hidden" name="action" value="update" />
     
    386381                        ?>
    387382                        <p><?php _e('<b>Warning!</b> Doing this will overwrite files and your database (depending on what was backed up).  A manual backup will be run prior to the restore.') ?></p>
     383                        <p>
     384                            <div style="float: left; padding-top: 2px;">
     385                                <input type="checkbox" checked="checked" id="use_existing_db" name="use_existing_db" value="1" />
     386                            </div>
     387                            <div style="margin-left: 1.5em;"><label for="use_existing_db">
     388                                <?php _e('Keep your current database settings by overwriting the settings (except the database prefix) in the backed up config file (if applicable).') ?>
     389                            </label></div>
     390                        </p>
    388391                        <p class="submit"><button id="restore-trigger" class="button"><?php _e('Restore from backup') ?></button></p>
    389392                    </div>
     
    405408                                var data = {
    406409                                    action: 'awb_restore',
    407                                     backup: $('input[name=restore-backup]:checked').val()
     410                                    backup: $('input[name=restore-backup]:checked').val(),
     411                                    use_existing_db: $("#use_existing_db:checked").length
    408412                                };
    409413                                if ( $("#ftp-hostname").length ) {
     
    425429                                        }
    426430                                       
    427                                         console.log(rsp);
    428                                         //window.location.reload();
     431                                        window.location.reload();
    429432                                    },
    430433                                    'json'
     
    518521            if ( in_array('database', $sections) ) {
    519522                $tables = $wpdb->get_col("SHOW TABLES LIKE '" . $wpdb->prefix . "%'");
    520                 //$result = shell_exec('mysqldump --add-drop-table --single-transaction -h ' . DB_HOST . ' -u ' . DB_USER . ' --password="' . DB_PASSWORD . '" ' . DB_NAME . ' ' . implode(' ', $tables) . ' > ' .  WP_CONTENT_DIR . '/uploads/awb/awb-database-backup.sql');
    521523                $sql = '';
    522524                foreach ( $tables as $table ) {
    523525                    $sql .= self::backup_table($table);
    524526                }
    525                 //print_r($sql);
     527
    526528                file_put_contents('awb-database-backup.sql', $sql);
    527529                $result = shell_exec('zip -u ' . $file . ' awb-database-backup.sql');
     
    704706        $wp_filesystem->delete($rdir . '/backup.zip');
    705707
     708        if ( isset($_POST['use_existing_db']) && $_POST['use_existing_db'] ) {
     709            $config_contents = $wp_filesystem->get_contents(trailingslashit($rdir) . 'wp-config.php');
     710            $config_contents = preg_replace(
     711                "|define\(.DB_NAME., .*\);|",
     712                "define('DB_NAME', '" . DB_NAME . "');",
     713                $config_contents
     714            );
     715            $config_contents = preg_replace(
     716                "|define\(.DB_USER., .*\);|",
     717                "define('DB_USER', '" . DB_USER . "');",
     718                $config_contents
     719            );
     720            $config_contents = preg_replace(
     721                "|define\(.DB_PASSWORD., .*\);|",
     722                "define('DB_PASSWORD', '" . DB_PASSWORD . "');",
     723                $config_contents
     724            );
     725            $config_contents = preg_replace(
     726                "|define\(.DB_HOST., .*\);|",
     727                "define('DB_HOST', '" . DB_HOST . "');",
     728                $config_contents
     729            );
     730            $wp_filesystem->put_contents(trailingslashit($rdir) . 'wp-config.php', $config_contents);
     731        }
     732        $wp_filesystem->delete($rdir . '/manifest.txt');
     733        echo $restore_dir;
     734       
    706735        $files = self::rscandir($restore_dir);
    707736        foreach ( $files as $file ) {
     
    710739                $wp_filesystem->mkdir($wp_filesystem->abspath() . dirname($file));
    711740            }
    712             @$wp_filesystem->move($rdir . $file, $wp_filesystem->abspath() . $file);
     741            @$wp_filesystem->move($rdir . $file, $wp_filesystem->abspath() . $file, true);
    713742        }
    714743
  • automatic-wordpress-backup/trunk/readme.txt

    r186383 r201698  
    1919able to create the zips for backup.
    2020
    21 For full info and installation instructions, visit http://www.wordpressbackup.org
     21For full info and installation instructions, visit http://www.webdesigncompany.net/automatic-wordpress-backup/
    2222
    2323== Installation ==
Note: See TracChangeset for help on using the changeset viewer.