WordPress.org

Plugin Directory

Changeset 619952


Ignore:
Timestamp:
11/01/12 19:09:21 (18 months ago)
Author:
Ipstenu
Message:

Tagging 2.0 - Now with backup retention tricks

Location:
dreamobjects
Files:
4 edited
12 copied

Legend:

Unmodified
Added
Removed
  • dreamobjects/tags/2.0/admin/backups.php

    r611200 r619952  
    4545                    <input type="hidden" name="action" value="update" /> 
    4646                    <?php wp_nonce_field('update-options'); ?> 
    47                     <input type="hidden" name="page_options" value="dh-do-bucket,dh-do-backupsection,dh-do-schedule" /> 
     47                    <input type="hidden" name="page_options" value="dh-do-bucket,dh-do-backupsection,dh-do-schedule,dh-do-retain" /> 
    4848 
    4949<table class="form-table"> 
     
    8989                </td> 
    9090        </tr> 
     91         
    9192        <tr valign="top"> 
    9293            <th scope="row"><label for="dh-do-schedule"><?php _e('Schedule', dreamobjects); ?></label></th> 
    93             <td><select name="dh-do-schedule"> 
     94            <td> 
     95                <select name="dh-do-schedule"> 
    9496                                <?php foreach ( array('Disabled','Daily','Weekly','Monthly') as $s ) : ?> 
    9597                                    <option value="<?php echo strtolower($s) ?>" <?php if ( strtolower($s) == get_option('dh-do-schedule') ) echo 'selected="selected"' ?>><?php echo $s ?></option> 
    9698                                <?php endforeach; ?> 
    97                 </select></td> 
    98         </tr> 
    99          
    100         <tr valign="top"> 
    101         <th scope="row"></th> 
    102         <td><?php 
     99                </select> 
     100                <?php 
    103101                  $timestamp = wp_next_scheduled( 'dh-do-backup' );  
    104102                  $nextbackup = sprintf(__('Next scheduled backup is at %s', dreamobjects), get_date_from_gmt( date('Y-m-d H:i:s', $timestamp) , 'F j, Y h:i a' ) ); 
     
    108106            <p class="description"><?php echo $nextbackup; ?></p> 
    109107            <?php } // Show next scheduled ?> 
    110         </td> 
    111         </tr>         
     108                </td> 
     109        </tr> 
     110        <tr valign="top"> 
     111            <th scope="row"><label for="dh-do-retain"><?php _e('Backup Retention', dreamobjects); ?></label></th> 
     112            <td>                 
     113                <select name="dh-do-retain"> 
     114                    <?php foreach ( array('15','30','60','90','all') as $s ) : ?> 
     115                        <option value="<?php echo strtolower($s) ?>" <?php if ( strtolower($s) == get_option('dh-do-retain') ) echo 'selected="selected"' ?>><?php echo $s ?></option> 
     116                    <?php endforeach; ?> 
     117                </select>    
     118                <p class="description"><?php _e('How many many backups do you want to keep? 30 is recommended.', dreamobjects); ?></p> 
     119                <p class="description"><strong><?php _e('NOTICE!', dreamobjects); ?></strong> <?php _e('DreamObjects charges you based on diskspace used. Setting to \'All\' will retain your backups forwever, however this can cost you a large sum of money over time. Please use cautiously!', dreamobjects); ?></p> 
     120                </td> 
     121        </tr> 
     122         
     123        <tr valign="top"> 
     124        <th scope="row"></th> 
     125        <td>        </td> 
     126        </tr> 
     127    
    112128<?php endif;  
    113129// ENDS how bucket list ?> 
     
    120136                 
    121137<?php if ( get_option('dh-do-bucket') && ( !get_option('dh-do-bucket') || (get_option('dh-do-bucket') != "XXXX") ) ) { ?> 
    122                 <h3><?php _e('Latest Ten Backups', dreamobjects); ?></h3> 
    123                 <p><?php _e('You can download the backups if you\'re logged into DreamObjects.', dreamobjects); ?></p> 
     138                <?php  
     139                    $num_backups = get_option('dh-do-retain'); 
     140                    if ( $num_backups == 'all') { $num_backups = 'WP';} 
     141                    $show_backup_header = sprintf(__('Latest %s Backups', dreamobjects),$num_backups );  
     142                ?> 
     143                <h3><?php echo $show_backup_header; ?></h3> 
     144                <p><?php _e('All backups can be downloaded from this page without logging in to DreamObjects.', dreamobjects); ?></p> 
    124145 
    125146                <div id="backups"> 
    126                     <ul> 
     147                    <ol> 
    127148                    <?php  
    128149                        if ( get_option('dh-do-bucket') ) { 
     
    135156            $object = apply_filters('dh-do-backup-item', $object); 
    136157                                 
    137             if ( ++$count > 10 ) break; 
     158            if ( ($num_backups != 'WP') && ( ++$count > $num_backups) ) break; 
    138159            ?><li><a href="<?php echo $s3->getAuthenticatedURL(get_option('dh-do-bucket'), $object['name'], 3600, false, true); ?>"><?php echo $object['label']; ?></a></li><?php 
    139160        } 
     
    141162                        } // if you picked a bucket 
    142163                    ?> 
    143                     </ul> 
     164                    </ol> 
    144165                </div> 
    145166 
  • dreamobjects/tags/2.0/admin/help.php

    r611200 r619952  
    8585        '<h3>' . __('DreamObjects Backups', 'dreamobjects') .'</h3>' . 
    8686        '<p>' . __( 'Backing up your WordPress site to DreamObjects will allow you to have a safe and secure backup of your site. This is useful to run before you upgrade WordPress, or make big changes.', 'dreamobjects' ) . '</p>' . 
    87         '<p>' . __( 'Backups can be scheduled to run daily, weekly or monthly. You also have the option to run a backup right now.', 'dreamobjects' ) . '</p>' 
     87        '<p>' . __( 'Backups can be scheduled to run daily, weekly or monthly. You also have the option to run a backup right now.', 'dreamobjects' ) . '</p>' . 
     88        '<p>' . __( 'The default backup retention is 15 backups, however you can change this t0 30, 60, 90, or all backups (where \'all\' io all backups, forever and ever). Keep in mind you will be charged for the space you use, so chose wisely.', 'dreamobjects' ) . '</p>' 
    8889      )); 
    8990    } 
  • dreamobjects/tags/2.0/dreamobjects.php

    r611200 r619952  
    55Plugin URI: https://github.com/Ipstenu/dreamobjects 
    66Description: Integrate your WordPress install with DreamHost DreamObjects 
    7 Version: 1.2 
     7Version: 2.0 
    88Author: Mika Epstein 
    99Author URI: http://ipstenu.org/ 
     
    207207        require_once(ABSPATH . '/wp-admin/includes/class-pclzip.php'); 
    208208 
     209        // Pull in data for what to backup 
    209210        $sections = get_option('dh-do-backupsection'); 
    210211        if ( !$sections ) { 
     
    215216        $zip = new PclZip($file); 
    216217        $backups = array(); 
     218 
    217219 
    218220        // All me files! 
     
    236238            @unlink(WP_CONTENT_DIR . '/upgrade/dreamobject-db-backup.sql'); 
    237239        } 
     240         
     241         
     242        // Cleanup Old Backups 
     243        if ( get_option('dh-do-retain') && get_option('dh-do-retain') != 'all' ) { 
     244            $num_backups = get_option('dh-do-retain'); 
     245             
     246            $s3 = new S3(get_option('dh-do-key'), get_option('dh-do-secretkey')); 
     247            if (($backups = $s3->getBucket(get_option('dh-do-bucket'), next(explode('//', get_bloginfo('siteurl'))) ) ) !== false) { 
     248                krsort($backups); 
     249                $count = 0; 
     250                foreach ($backups as $object) { 
     251                    if ( ++$count > $num_backups ) { 
     252                        $s3->deleteObject(get_option('dh-do-bucket'), $object['name']); 
     253                    }     
     254                } 
     255            } 
     256        } 
    238257    } 
    239258     
  • dreamobjects/tags/2.0/readme.txt

    r611200 r619952  
    44Requires at least: 3.4 
    55Tested up to: 3.5 
    6 Stable tag: 1.2 
     6Stable tag: 2.0 
    77License: GPLv2 or later 
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     
    1818= Backup Features = 
    1919* Automatically backs up your site (DB and files) to your DreamObjects cloud on a daily, weekly, or monthly schedule. 
     20* Retains 15, 30, 60, or 90 backups at any given time (so as not to charge you the moon when you have a large site). 
    2021* Provides <a href="https://github.com/wp-cli/wp-cli#what-is-wp-cli">wp-cli</a> hooks to do the same 
    2122 
     
    5455Yes and no. You have to use Dream<em>Objects</em>, which belongs to Dream<em>Host</em>. This plugin was built on and specifically for DreamHost servers, so there's no assurance it'll work on other hosts. 
    5556 
     57= Can I use this on a Windows Server? = 
     58 
     59You can try, and let me know how it goes. I built this for DreamHost, so it has only been tested on Linux boxes. 
     60 
    5661= How often can I schedule backups? = 
    5762 
     
    6166 
    6267Yep! It actually sets it to run in 60 seconds, but works out the same. 
     68 
     69= How long does it keep backups for? = 
     70 
     71Since you get charged on space used for DreamObjects, the default is to retain the last 15 backups. If you need more, you can save up to 90 backups, however that's rarely needed. 
     72 
     73= Can I keep them forever? = 
     74 
     75If you chose 'all' then yes, however this is not recommended. DreamObjects (like most S3/cloud platforms) charges you based on space and bandwidth, so if you have a large amount of files stored, you will be charged more money. 
    6376 
    6477= Who can upload files? = 
     
    80931. The Settings Page 
    81941. The backup page 
    82 1. The uploader page 
     951. The uploader page, as seen by Admins 
    83961. The uploader page, as seen by Authors 
    8497 
    8598== Changelog == 
     99 
     100= Version 2.0 = 
     101Nov 1, 2012 by Ipstenu 
     102 
     103* Backup retention - chose your own adventure. 
    86104 
    87105= Version 1.2 = 
     
    93111 
    94112= Version 1.1 = 
    95 Sept 27, 2012 by Ipstenu <em>All minor changes, but since people had been using 1.0, I thought a kick was in order.</em> 
     113Sept 27, 2012 by Ipstenu  
    96114 
     115* <em>All minor changes, but since people had been using 1.0, I thought a kick was in order.</em> 
    97116* Security (nonce, abspath, etc) 
    98117* Better defines 
     
    106125* Upgraded <a href="http://undesigned.org.za/2007/10/22/amazon-s3-php-class">Amazon S3 PHP Class</a> to latest version 
    107126* Pretified, consolidated, organized, and formatted. 
    108 * Saving files to upgrade (vs it's own folder) 
     127* Saving temp files to upgrade (vs it's own folder) 
    109128 
    110129== Upgrade notice == 
  • dreamobjects/trunk/admin/backups.php

    r611200 r619952  
    4545                    <input type="hidden" name="action" value="update" /> 
    4646                    <?php wp_nonce_field('update-options'); ?> 
    47                     <input type="hidden" name="page_options" value="dh-do-bucket,dh-do-backupsection,dh-do-schedule" /> 
     47                    <input type="hidden" name="page_options" value="dh-do-bucket,dh-do-backupsection,dh-do-schedule,dh-do-retain" /> 
    4848 
    4949<table class="form-table"> 
     
    8989                </td> 
    9090        </tr> 
     91         
    9192        <tr valign="top"> 
    9293            <th scope="row"><label for="dh-do-schedule"><?php _e('Schedule', dreamobjects); ?></label></th> 
    93             <td><select name="dh-do-schedule"> 
     94            <td> 
     95                <select name="dh-do-schedule"> 
    9496                                <?php foreach ( array('Disabled','Daily','Weekly','Monthly') as $s ) : ?> 
    9597                                    <option value="<?php echo strtolower($s) ?>" <?php if ( strtolower($s) == get_option('dh-do-schedule') ) echo 'selected="selected"' ?>><?php echo $s ?></option> 
    9698                                <?php endforeach; ?> 
    97                 </select></td> 
    98         </tr> 
    99          
    100         <tr valign="top"> 
    101         <th scope="row"></th> 
    102         <td><?php 
     99                </select> 
     100                <?php 
    103101                  $timestamp = wp_next_scheduled( 'dh-do-backup' );  
    104102                  $nextbackup = sprintf(__('Next scheduled backup is at %s', dreamobjects), get_date_from_gmt( date('Y-m-d H:i:s', $timestamp) , 'F j, Y h:i a' ) ); 
     
    108106            <p class="description"><?php echo $nextbackup; ?></p> 
    109107            <?php } // Show next scheduled ?> 
    110         </td> 
    111         </tr>         
     108                </td> 
     109        </tr> 
     110        <tr valign="top"> 
     111            <th scope="row"><label for="dh-do-retain"><?php _e('Backup Retention', dreamobjects); ?></label></th> 
     112            <td>                 
     113                <select name="dh-do-retain"> 
     114                    <?php foreach ( array('15','30','60','90','all') as $s ) : ?> 
     115                        <option value="<?php echo strtolower($s) ?>" <?php if ( strtolower($s) == get_option('dh-do-retain') ) echo 'selected="selected"' ?>><?php echo $s ?></option> 
     116                    <?php endforeach; ?> 
     117                </select>    
     118                <p class="description"><?php _e('How many many backups do you want to keep? 30 is recommended.', dreamobjects); ?></p> 
     119                <p class="description"><strong><?php _e('NOTICE!', dreamobjects); ?></strong> <?php _e('DreamObjects charges you based on diskspace used. Setting to \'All\' will retain your backups forwever, however this can cost you a large sum of money over time. Please use cautiously!', dreamobjects); ?></p> 
     120                </td> 
     121        </tr> 
     122         
     123        <tr valign="top"> 
     124        <th scope="row"></th> 
     125        <td>        </td> 
     126        </tr> 
     127    
    112128<?php endif;  
    113129// ENDS how bucket list ?> 
     
    120136                 
    121137<?php if ( get_option('dh-do-bucket') && ( !get_option('dh-do-bucket') || (get_option('dh-do-bucket') != "XXXX") ) ) { ?> 
    122                 <h3><?php _e('Latest Ten Backups', dreamobjects); ?></h3> 
    123                 <p><?php _e('You can download the backups if you\'re logged into DreamObjects.', dreamobjects); ?></p> 
     138                <?php  
     139                    $num_backups = get_option('dh-do-retain'); 
     140                    if ( $num_backups == 'all') { $num_backups = 'WP';} 
     141                    $show_backup_header = sprintf(__('Latest %s Backups', dreamobjects),$num_backups );  
     142                ?> 
     143                <h3><?php echo $show_backup_header; ?></h3> 
     144                <p><?php _e('All backups can be downloaded from this page without logging in to DreamObjects.', dreamobjects); ?></p> 
    124145 
    125146                <div id="backups"> 
    126                     <ul> 
     147                    <ol> 
    127148                    <?php  
    128149                        if ( get_option('dh-do-bucket') ) { 
     
    135156            $object = apply_filters('dh-do-backup-item', $object); 
    136157                                 
    137             if ( ++$count > 10 ) break; 
     158            if ( ($num_backups != 'WP') && ( ++$count > $num_backups) ) break; 
    138159            ?><li><a href="<?php echo $s3->getAuthenticatedURL(get_option('dh-do-bucket'), $object['name'], 3600, false, true); ?>"><?php echo $object['label']; ?></a></li><?php 
    139160        } 
     
    141162                        } // if you picked a bucket 
    142163                    ?> 
    143                     </ul> 
     164                    </ol> 
    144165                </div> 
    145166 
  • dreamobjects/trunk/admin/help.php

    r611200 r619952  
    8585        '<h3>' . __('DreamObjects Backups', 'dreamobjects') .'</h3>' . 
    8686        '<p>' . __( 'Backing up your WordPress site to DreamObjects will allow you to have a safe and secure backup of your site. This is useful to run before you upgrade WordPress, or make big changes.', 'dreamobjects' ) . '</p>' . 
    87         '<p>' . __( 'Backups can be scheduled to run daily, weekly or monthly. You also have the option to run a backup right now.', 'dreamobjects' ) . '</p>' 
     87        '<p>' . __( 'Backups can be scheduled to run daily, weekly or monthly. You also have the option to run a backup right now.', 'dreamobjects' ) . '</p>' . 
     88        '<p>' . __( 'The default backup retention is 15 backups, however you can change this t0 30, 60, 90, or all backups (where \'all\' io all backups, forever and ever). Keep in mind you will be charged for the space you use, so chose wisely.', 'dreamobjects' ) . '</p>' 
    8889      )); 
    8990    } 
  • dreamobjects/trunk/dreamobjects.php

    r611200 r619952  
    55Plugin URI: https://github.com/Ipstenu/dreamobjects 
    66Description: Integrate your WordPress install with DreamHost DreamObjects 
    7 Version: 1.2 
     7Version: 2.0 
    88Author: Mika Epstein 
    99Author URI: http://ipstenu.org/ 
     
    207207        require_once(ABSPATH . '/wp-admin/includes/class-pclzip.php'); 
    208208 
     209        // Pull in data for what to backup 
    209210        $sections = get_option('dh-do-backupsection'); 
    210211        if ( !$sections ) { 
     
    215216        $zip = new PclZip($file); 
    216217        $backups = array(); 
     218 
    217219 
    218220        // All me files! 
     
    236238            @unlink(WP_CONTENT_DIR . '/upgrade/dreamobject-db-backup.sql'); 
    237239        } 
     240         
     241         
     242        // Cleanup Old Backups 
     243        if ( get_option('dh-do-retain') && get_option('dh-do-retain') != 'all' ) { 
     244            $num_backups = get_option('dh-do-retain'); 
     245             
     246            $s3 = new S3(get_option('dh-do-key'), get_option('dh-do-secretkey')); 
     247            if (($backups = $s3->getBucket(get_option('dh-do-bucket'), next(explode('//', get_bloginfo('siteurl'))) ) ) !== false) { 
     248                krsort($backups); 
     249                $count = 0; 
     250                foreach ($backups as $object) { 
     251                    if ( ++$count > $num_backups ) { 
     252                        $s3->deleteObject(get_option('dh-do-bucket'), $object['name']); 
     253                    }     
     254                } 
     255            } 
     256        } 
    238257    } 
    239258     
  • dreamobjects/trunk/readme.txt

    r611200 r619952  
    44Requires at least: 3.4 
    55Tested up to: 3.5 
    6 Stable tag: 1.2 
     6Stable tag: 2.0 
    77License: GPLv2 or later 
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     
    1818= Backup Features = 
    1919* Automatically backs up your site (DB and files) to your DreamObjects cloud on a daily, weekly, or monthly schedule. 
     20* Retains 15, 30, 60, or 90 backups at any given time (so as not to charge you the moon when you have a large site). 
    2021* Provides <a href="https://github.com/wp-cli/wp-cli#what-is-wp-cli">wp-cli</a> hooks to do the same 
    2122 
     
    5455Yes and no. You have to use Dream<em>Objects</em>, which belongs to Dream<em>Host</em>. This plugin was built on and specifically for DreamHost servers, so there's no assurance it'll work on other hosts. 
    5556 
     57= Can I use this on a Windows Server? = 
     58 
     59You can try, and let me know how it goes. I built this for DreamHost, so it has only been tested on Linux boxes. 
     60 
    5661= How often can I schedule backups? = 
    5762 
     
    6166 
    6267Yep! It actually sets it to run in 60 seconds, but works out the same. 
     68 
     69= How long does it keep backups for? = 
     70 
     71Since you get charged on space used for DreamObjects, the default is to retain the last 15 backups. If you need more, you can save up to 90 backups, however that's rarely needed. 
     72 
     73= Can I keep them forever? = 
     74 
     75If you chose 'all' then yes, however this is not recommended. DreamObjects (like most S3/cloud platforms) charges you based on space and bandwidth, so if you have a large amount of files stored, you will be charged more money. 
    6376 
    6477= Who can upload files? = 
     
    80931. The Settings Page 
    81941. The backup page 
    82 1. The uploader page 
     951. The uploader page, as seen by Admins 
    83961. The uploader page, as seen by Authors 
    8497 
    8598== Changelog == 
     99 
     100= Version 2.0 = 
     101Nov 1, 2012 by Ipstenu 
     102 
     103* Backup retention - chose your own adventure. 
    86104 
    87105= Version 1.2 = 
     
    93111 
    94112= Version 1.1 = 
    95 Sept 27, 2012 by Ipstenu <em>All minor changes, but since people had been using 1.0, I thought a kick was in order.</em> 
     113Sept 27, 2012 by Ipstenu  
    96114 
     115* <em>All minor changes, but since people had been using 1.0, I thought a kick was in order.</em> 
    97116* Security (nonce, abspath, etc) 
    98117* Better defines 
     
    106125* Upgraded <a href="http://undesigned.org.za/2007/10/22/amazon-s3-php-class">Amazon S3 PHP Class</a> to latest version 
    107126* Pretified, consolidated, organized, and formatted. 
    108 * Saving files to upgrade (vs it's own folder) 
     127* Saving temp files to upgrade (vs it's own folder) 
    109128 
    110129== Upgrade notice == 
Note: See TracChangeset for help on using the changeset viewer.