Welcome Guest, Not a member yet? Register   Sign In
Site Backup Manager
#3

[eluser]rip_pit[/eluser]
so i tested it online (live) and it works like a charm !

here are some mods that i used to customise that might be helpfull to someone :
* Get the top root path (get /public/ instead of /public/www/ ) where to store the backup
* require a password to execute
* reuse already set config values for dbname, paths, etc.

controllers/cron.php including the mods :
Code:
class Cron extends CI_Controller
{

  /**
   * error message if unauthorized
   * @var str
   */
  var $err_message = "unauthorized access.";

  /**
   *
   */
  function index() {
    show_error($this->err_message,'401');
  }

  
  /**
   * auto backup auto
   *
   * @param str $userpwd, include the pass in the 1st segment of url. should match with the password value into $required_url_password
   * Eg. website.com/cron/backup/YourPassword
   */
public function backup($userpwd=null)
{

    // require passw in url to autorize execution
    $required_url_password = 'YourPassword';
    if ( !isset($userpwd) || !$userpwd || $userpwd !== $required_url_password )
      show_error($this->err_message,'401');


  //if you have previously connected to the FTP server make sure you have closed the connection
  //$this->ftp->close();  

    // format path to have a real path, and not a path ending with /../
    $base_path = realpath(BASEPATH."../") . '/';
    //get the top root path

    //the backup library requires that you have already connected to your database

    $prefs = array( "base_path"   => $base_path,
      //etc. set the rest of the config
      "backup_dir"  => "backups", //the folder that you will use on this server to hold the backup files
      /* Set this for multiple databases and comment out the ignore_table and backup_tables elements */
      "backup_information" =>  array(
              array( "database"     => $this->db->database,
                "active_group"  => 'default', //set in the config/database.php
                "ignore_table" => array(), //containts a list of all the tables to ignore, leave empty to backup all
                "backup_tables" => array() //contains a list of all the tables that need backing up, leave empty to backup all
              )
             ),
      /* or set these and leave the backup_information commented out */
      #"ignore_table"  => array(), //ignores tables in the database you are connected to
      #"backup_tables" => array(), //backs up only these tables in the database you are connected to
        
      "ftp_transfer"  => false, //true = attempts to connect to the FTP server to transfer your backup files, false = stores files locally only
      "ftp_server"  => "ftp.domain.com", //the ftp URL
      "ftp_user"   => "ftp_user", //the ftp username
      "ftp_pass"   => "ftp_pass", //the ftp password
      "ftp_base_path"  => "", //if your site is located in a public_html folder or other like this. No /(slash) required
      "ftp_port"   => 21, //the ftp port number
      "remote_dir"  => "remote_folder", //the folder on the remote server where the FTP will place files this can be a directory like `home/domain/folder`
        
      "send_email"  => false, //true = sends backup files to the email address if it is able to, false = doesn't attempt an email
      "email_addresses" => array(config_item('admin_email')), //email address(es) that the backup will be sent to
      "email_from"  => config_item('admin_email'), //the email address that the backup email will be from
      "email_from_name" => "Backup Script", //the name that the backup email will be from
      "max_mail_size"  => 0, //the max size in bytes that the email account can receive

      "file_backup"  => true, //true = backup the site files, false = just the databases
      "directories"   => array(), //empty array backups everything or you can list directories to backup array("application", "forum", "resources/uploads")
      "copy_directory" => "backup_files_temp" //this is the temp directory that is used when creating a backup of the site files);


                $this->load->library("backup");
  
  $this->backup->init($prefs);
  $this->backup->run();
  
}

}


Messages In This Thread
Site Backup Manager - by El Forum - 09-27-2011, 09:27 AM
Site Backup Manager - by El Forum - 11-08-2012, 04:35 PM
Site Backup Manager - by El Forum - 11-09-2012, 06:58 PM
Site Backup Manager - by El Forum - 01-07-2013, 10:17 AM
Site Backup Manager - by El Forum - 01-09-2013, 04:45 PM
Site Backup Manager - by El Forum - 01-27-2013, 08:13 AM
Site Backup Manager - by El Forum - 01-28-2013, 04:30 AM
Site Backup Manager - by El Forum - 07-18-2013, 12:08 AM



Theme © iAndrew 2016 - Forum software by © MyBB