Commits

mic2100 committed 67af691

allow multiple databases to be backed up.

  • Participants
  • Parent commits a3eed6b

Comments (0)

Files changed (2)

application/controllers/cron.php

 			
 		$prefs = array(	"base_path" 		=> "D:/xampp/htdocs/backup_library_1.2/", //the base path on your server when the file are located
 						"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" 		=> "database_name",
+																"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

application/libraries/backup.php

-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-
-/**
-* CodeIgniter 2.0.0 Backup Library
-*
-* REQUIRES PHP 5+
-* 
-* Will create backups of the mysql DB, requires that the mysql driver be used not the mysqli
-* Backups are created daily, weekly and monthly from the day they are first run. Old backups
-* will be removed after the pre-defined amount of prior backups has completed first.
-* Options to FTP to external site and/or email to one or more email addresses
-* Will also backup all or selected files from the site. These will be in the same zip file as
-* the sql backup.
-* This is ideally run under a CRON job because it may take a very long time to run.
-* IMPORTANT: Please connect to your database before running this script or an error
-* will be generated.
-* 
-* 1.1 to 1.2 (2011-09-20)
-* File backup was unable to back the entire site, this has now been changed and providing 
-* an empty $directories array will backup all files located in the site. 
-* The temp directory is removed once the script has finished with it backing up all the files.
-*
-* 1.0 to 1.1 (2011-07-13)
-* File backup was added to allows the site files to be backed up in the same zip file
-* Options were added to allow files backups or not.
-*
-* @author Michael Bardsley
-* @site http://www.mic-b.co.uk/
-* @email me@mic-b.co.uk
-* @version    1.2 Beta
-*/
-
-class Backup
-{
-	
-	private $CI; //holds the CodeIgniter instance
-	
-	//base path of the site i.e. <drive>:/<folder>/<folder>/ or /<folder>/<folder>/
-	//this can be setup in the constructor unless you want a static route
-	public $base_path = ""; 
-	
-	private $ext = "zip"; //zip
-	
-	public $backup_dir = "backup"; //directory that the backups are stored in
-	
-	public $remote_dir = "FTP Folder"; //the directory that is created/used on the ftp server
-	
-	private $remove_old = true; //whether to remove the old files or not
-	
-	public $ignore_table = array(); //containts a list of all the tables to ignore, leave empty to backup all
-	
-	public $backup_tables = array(); //contains a list of all the tables that need backing up, leave empty to backup all
-	
-	//whether or not to upload the files to an external FTP server
-	//Please note if you enable this after it being false the old files will also be copied to the FTP server
-	public $ftp_transfer = false;
-	
-	//if the above it set to true then you MUST enter the FTP connection details below
-	//ftp server
-	public $ftp_server = "ftp url";
-	
-	//ftp username
-	public $ftp_user = "ftp username";
-	
-	//ftp password
-	public $ftp_pass = "ftp password";
-	
-	//the base FTP path if required
-	public $ftp_base_path = ""; //no trailing / required
-	
-	//the FTP port number, default 21
-	public $ftp_port = 21;
-	
-	//send the backup to an email address
-	public $send_email = false;
-	
-	//the addresses that the backup will be sent to if $sent_mail is true
-	public $email_addresses = array("email@domain.com");
-	
-	//the address the emails will be sent from
-	public $email_from = "auto-backup@domain.com";
-	
-	//the name used when the emails are sent
-	public $email_from_name = "Auto Backup";
-	
-	//mailbox max file size, change this is you know that you email address can support bigger sizes
-	public $max_mail_size = 10485760; //set to 10485760 = 10MB as default - this number is in bytes. set to 0 for unlimited size
-
-	//these are the folder names that are created on the server and the backups are placed in these
-	private $folder_names = array("daily" => "daily", "weekly" => "weekly", "monthly" => "monthly", "quarterly" => "quarterly");
-	
-	//these are the filenames that are used when creating the files
-	private $file_names = array("daily" => "_daily_backup", "weekly" => "_weekly_backup", "monthly" => "_monthly_backup", "quarterly" => "_quarterly_backup");
-
-	//this is an array that hold the number of backups to keep for each type
-	private $save_info = array("daily" => 14, "weekly" => 6, "monthly" => 3, "quarterly" => 2);
-		
-	//backup site files
-	public $file_backup = true;
-	
-	//folder names to backup that are in the same directory as the CI index.php
-	//these can either be just 1 folder name "application" or a path like "application/controllers"
-	//if this array is empty the entire site structure is backed up (NOTICED BUG - will also backup the previous backup files making it a very large file)
-	//public $directories = array("application", "forum", "resources/framework", "resources/framework_addons", "resources/images", "resources/js", "resources/styles", "resources/uploads", "system");
-	public $directories = array();
-	
-	//the directory name used for the temp file copy when everything is backed up
-	public $copy_directory = "site_files";
-	
-	//used to mark that the directory structure has alread been copied
-	private $structure_copied = false;
-	
-	/*
-	* __construct
-	*
-	* this is the main function called, this will be the only function you have to call
-	*
-	* @access public
-	*
-	*/
-		
-	public function __construct()
-	{
-		
-        if(!isset($this->CI))
-        {
-            $this->CI =& get_instance(); //get the CI instance
-        } //if(!isset($this->CI))
-	
-	} //public function __construct()
-	
-	public function init($prefs = array())
-	{
-
-		if(is_array($prefs) and count($prefs) > 0):
-		
-			foreach($prefs as $var => $value):
-
-				$this->$var = $value;
-			
-			endforeach; //foreach($prefs as $var => $value):
-		
-		endif; //if(is_array($prefs) and count($prefs) > 0):
-
-		//load the required CI helpers
-		$this->CI->load->helper("file");
-		$this->CI->load->helper("directory");
-		
-		//first we check to make sure all the directories are created where wanted so save our documents
-		$this->check_directories();
-		echo "Directories created successfully...<br />";
-		
-		//load the required CI libraries
-		if($this->ftp_transfer === true)
-		{
-			
-			$this->CI->load->library("ftp");	
-			//connect to the FTP server
-			$this->connect_ftp();
-			$this->check_ftp_directories();
-			echo "FTP Directories created successfully...<br />";
-			
-		} //if($this->ftp_transfer === true)
-		if($this->send_email === true)
-		{
-			
-			$this->CI->load->library("email");
-				
-		} //if($this->send_email === true)		
-		
-	} //public function init($prefs = array())
-
-	/*
-	* run
-	*
-	* this is the main function called, this will be the only function you have to call
-	*
-	* @access public
-	*
-	*/
-	
-	public function run($end = true)
-	{
-		
-		//adjust the next to rows as required
-		ini_set("memory_limit", "64M"); //changes the amount of memory that the script is allowed to use
-		//WARNING I have had to increase this to very larage amounts because of the memory requirement of the zip encoding class
-		set_time_limit(0); //sets the time limit for the script, is set to 0 so it will run until it is complete
-		
-		//load the CI backup utility
-		$this->CI->load->dbutil(); //used in the run backup function to backup the database
-		
-		//run the quarterly backups
-		$this->run_backup("quarterly");
-		flush();	
-		//run the monthly backups
-		$this->run_backup("monthly");
-		flush();
-		//run the weekly backups
-		$this->run_backup("weekly");
-		flush();
-		//run the daily backups
-		$this->run_backup("daily");
-		flush();
-		
-		//close the FTP connection if it is required
-		if($this->ftp_transfer === true)
-		{
-		
-			$this->CI->ftp->close();	
-			
-		} //if($this->ftp_transfer === true)
-		
-		if($this->structure_copied === true): //we need to remove the copied files to ensure that the server is kept nice and tidy
-		
-			$this->remove_temp_files($this->base_path.$this->copy_directory."/");	
-		
-		endif; //if($this->structure_copied === true):
-		
-		if($end === true):
-		
-			exit;
-		
-		endif;
-		
-		return true;
-		
-	} //public function run()
-
-	/*
-	* 
-	* run_backup
-	*
-	* runs the backup tasks
-	*
-	* @params string
-	* @return string
-	* @access private
-	*/
-
-	private function run_backup($type = "daily")
-	{
-		
-		$this->CI->load->library('zip');
-		
-		//the current location based on the type	
-		$location = $this->get_file_location($type);
-		
-		//the last file name
-		$last_file = $this->get_last_file($location, $type);
-
-		//will be the new backup file name
-		$filename = $this->get_file_name($type);
-
-		$prefs = array(
-			'tables'      => $this->backup_tables,  // Array of tables to backup.
-			'ignore'      => $this->ignore_table,	// List of tables to omit from the backup
-			'format'      => $this->ext,        	// zip, txt
-			'add_drop'    => TRUE,              	// Whether to add DROP TABLE statements to backup file
-			'add_insert'  => TRUE,              	// Whether to add INSERT data to backup file
-			'newline'     => "\n"               	// Newline character used in backup file
-		);
-		
-		//get a current backup of the database
-		$backup =& $this->CI->dbutil->backup($prefs);
-		
-		//check to see if the latest file is empty
-		if($last_file != "")
-		{
-	
-			//gets the latest backup files creation date
-			$file_date = substr($last_file, 0, 10);
-			//one month ago to check to see if the file need recreating or not
-			$diff = date("Y-m-d", $this->get_time_difference($type));
-			
-			//if it is one month or more ago we need to create a new monthly backup
-			if($file_date <= $diff)
-			{
-				
-				if($this->file_backup === true)
-				{
-				
-					$this->backup_site_files();
-				
-				} //if($this->file_backup === true)
-				
-				$this->CI->zip->archive($location.$filename);
-				
-				echo "Created new file: ".$location.$filename."<br />";
-
-				if($this->ftp_transfer === true)
-				{
-					$ftp_location = $this->get_ftp_location($type);
-					echo "Uploading file: ".$ftp_location.$filename." to remote server...<br />";
-					$this->CI->ftp->upload($location.$filename, $ftp_location.$filename, 'auto');
-						
-				} //if($this->ftp_transfer === true)
-				if($this->send_email === true)
-				{
-					
-					$this->send_email_process($location.$filename, $type);	
-						
-				} //if($this->send_email === true)
-							
-			}
-			else //no need to create the backup because it is not old enough
-			{
-				
-				echo "No need to create the ".$type." backup becuase one was completed recently...<br />";
-			
-			} //if($file_date <= $diff)
-			
-		}
-		else
-		{
-			
-			//create new backup
-			//write_file($location.$filename, $backup);
-			
-			if($this->file_backup === true)
-			{
-			
-				$this->backup_site_files();
-			
-			} //if($this->file_backup === true)
-			
-			$this->CI->zip->archive($location.$filename);
-
-			echo "Created new file: ".$location.$filename.".<br />";	
-
-			if($this->ftp_transfer === true)
-			{
-				$ftp_location = $this->get_ftp_location($type);
-				echo "Uploading file: ".$ftp_location.$filename." to remote server...<br />";
-				$this->CI->ftp->upload($location.$filename, $ftp_location.$filename, 'auto');
-					
-			} //if($this->ftp_transfer === true)
-			if($this->send_email === true)
-			{
-				
-				$this->send_email_process($location.$filename, $type);
-					
-			} //if($this->send_email === true)
-			
-		} //if($latest_file != "")
-
-		//remove old files if we have selected that feature
-		if($this->remove_old == true)
-		{
-			
-			$keep = $this->files_to_keep($type);
-			$this->remove_old_local_files($location, $keep, $type);
-			
-		} //if($this->remove_old == true)
-
-		$this->CI->zip->clear_data(); //clear the zip to prevent duplicate files being archived
-		
-		return;		
-		
-	} //private function run_backup($backup, $type)
-
-	/*
-	* 
-	* backup_site_files
-	*
-	* this backs up all the files located in the directories
-	* specified.
-	*
-	* @access private
-	*/
-	
-	private function backup_site_files()
-	{
-		
-		//loop each of the folder that will be backed up
-		if(count($this->directories) > 0):
-		
-			foreach($this->directories as $dir):
-				
-				$location = $this->base_path . $dir . "/";
-	
-				$this->CI->zip->read_dir($location);
-			
-			endforeach; //foreach($this->directories as $dir):
-		
-		else:
-			
-			//takes a opy of the code to ensure that backups of backups are not made.
-			if($this->structure_copied === false):
-				
-				$this->copy_site_files($this->base_path, $this->base_path.$this->copy_directory."/");
-			
-			endif;
-			
-			$this->CI->zip->read_dir($this->base_path.$this->copy_directory."/");
-		
-		endif;
-		
-		//$this->CI->zip->archive('my_backup.zip');	
-		
-	}
-
-	/*
-	* 
-	* copy_site_files
-	*
-	* this copies all the files located in the site
-	* specified.
-	*
-	* WRITTEN BY: cory at veck dot ca 30-Apr-2011 06:17 from the PHP manual copy comments
-	*
-	* @access private
-	*/
-	
-	private function copy_site_files($path, $dest)
-	{
-			
-        if( is_dir($path) )
-        {
-            @mkdir( $dest );
-            $objects = scandir($path);
-            if( sizeof($objects) > 0 )
-            {
-                foreach( $objects as $file )
-                {
-                    if( $file == "." || $file == ".." )
-                        continue;
-                    // go on
-                    if( is_dir( $path."/".$file ) )
-                    {
-                        
-						if($file != $this->backup_dir and $file != $this->copy_directory)
-						{	
-						
-							$this->copy_site_files($path."/".$file, $dest."/".$file );
-						
-						}
-						
-                    }
-                    else
-                    {
-                        copy( $path."/".$file, $dest."/".$file );
-                    }
-                }
-            }
-			$this->structure_copied = true;
-            return true;
-        }
-        elseif( is_file($path) )
-        {
-			$this->structure_copied = true;
-            return copy($path, $dest);
-        }
-        else
-        {
-			$this->structure_copied = true;
-            return false;
-        }			
-		
-	}
-
-	/*
-	* 
-	* remove_temp_files
-	*
-	* this removes all the files and directories located in the directory
-	*
-	* WRITTEN BY: O S 18-Jun-2010 10:30 from the PHP manual rmdir comments
-	*
-	* WANRING: if you run this on you base_path then all the files in the site will be deleted
-	*
-	* @access private
-	*/
-
-	private function remove_temp_files($directory) 
-	{
-		
-		if(substr($directory,-1) == "/") 
-		{
-			$directory = substr($directory,0,-1);
-		}
-	
-		if(!file_exists($directory) || !is_dir($directory)) 
-		{
-			return false;
-		} elseif(!is_readable($directory)) 
-		{
-			return false;
-		} 
-		else 
-		{
-			$directoryHandle = opendir($directory);
-		   
-			while ($contents = readdir($directoryHandle)) 
-			{
-				if($contents != '.' && $contents != '..') 
-				{
-					$path = $directory . "/" . $contents;
-				   
-					if(is_dir($path)) 
-					{
-						$this->remove_temp_files($path);
-					} 
-					else 
-					{
-						unlink($path);
-					}
-				}
-			}
-		   
-			closedir($directoryHandle);
-	
-			if(!rmdir($directory)) 
-			{
-				return false;
-			}
-			else
-			{		   
-				return true;
-			}
-		}
-	} 
-	
-	/*
-	* 
-	* send_email_process
-	*
-	* sends the emails to the emails addresses provided with the attachments
-	* this uses the CI send function so you will have to seup your email
-	* config details in the calling controller or a email.php in the config
-	* folder.
-	*
-	* @params string
-	* @params string
-	* @access private
-	*/
-
-	private function send_email_process($file, $type)
-	{
-		
-		$file_info = get_file_info($file); //get the file info so we can check if the size is allowed
-		
-		//if the size is within the max allowed size for this mail box then send the emails
-		if($file_info['size'] < (int)$this->max_mail_size || (int)$this->max_mail_size == 0)
-		{
-			
-			foreach($this->email_addresses as $key => $email)
-			{
-			
-				$this->CI->email->clear(true);
-			
-				$this->CI->email->from($this->email_from, $this->email_from_name);
-				$this->CI->email->to($email);
-				
-				$this->CI->email->subject($type. " - Auto Backup");
-				$this->CI->email->message('Auto Backup - please find new backup attached to this email.');
-				$this->CI->email->attach($file);
-				
-				$this->CI->email->send();
-				
-				//echo $this->CI->email->print_debugger();
-			
-			} //foreach($this->email_addresses as $key => $email)
-		
-		}
-		else
-		{
-			
-			echo "File: ".$file." (".$file_info['size'].") exceeds the mail box limit of ".$this->max_mail_size;
-			
-		} //if($file_info['size'] < $this->max_mail_size)
-		
-	} //private function send_email_process($file, $type)
-
-	/*
-	* 
-	* check_ftp_directory
-	*
-	* checks the ftp directory to make sure it exists before we attempt to create the file
-	*
-	* @params string
-	* @access private
-	*/
-	
-	private function check_ftp_directory($path)
-	{
-
-		//if the directory does not exist we create it
-		if($this->CI->ftp->changedir($path, true) === false)
-		{
-		
-			$this->CI->ftp->mkdir($path, DIR_WRITE_MODE);
-		
-		} //if($this->CI->ftp->changedir($path, true) === false)
-		
-		return;
-		
-	} //private function check_ftp_directory($path)
-
-	/*
-	* 
-	* check_ftp_directories
-	*
-	* checks the ftp directories to make sure they exist before we attempt to create the files
-	*
-	* @access private
-	*/
-		
-	private function check_ftp_directories()
-	{
-		
-		//check to make sure the main backup folder exists
-		$base_check = (($this->ftp_base_path == "/" or $this->ftp_base_path == "")? "": "/".$this->ftp_base_path)."/".$this->remote_dir."/";
-		
-		//if there is additional base path set then we need to make sure we can navigate to it
-		if($this->ftp_base_path != "/" and $this->ftp_base_path != "")
-		{
-			
-			if(strpos($this->ftp_base_path, "/") > 0)
-			{
-				
-				$directories = explode("/", $this->ftp_base_path);
-				
-				if(is_array($directories) and count($directories) > 0)
-				{
-					
-					$path = "";
-					
-					//loop each of the directories
-					foreach($directories as $key => $directory)
-					{
-						
-						if(strlen($directory) > 0)
-						{
-						
-							$path .= "/".$directory;
-							$this->check_ftp_directory($path);
-						
-						} //if(strlen($directory) > 0)
-					
-					} //foreach($directories as $key => $directory)
-					
-				}
-				else
-				{
-					
-					$this->check_ftp_directory("/".str_replace("/", "", $this->ftp_base_path));
-					
-				} //if(is_array($directories) and count($directories) > 0)
-				
-			}
-			else
-			{
-				
-				$this->check_ftp_directory("/".$this->ftp_base_path);
-				
-			} //if(strpos($this->ftp_base_path, "/") > 0)
-
-			
-		} //if($this->ftp_base_path != "/" and $this->ftp_base_path != "")
-
-		$this->check_ftp_directory($base_check);
-	
-		$this->CI->ftp->upload($this->base_path . $this->backup_dir."/.htaccess", $base_check.".htaccess", "auto");
-
-		$quarterly_path = $this->get_ftp_location("quarterly");
-
-		$this->check_ftp_directory($quarterly_path);
-
-		$monthly_path = $this->get_ftp_location("monthly");
-
-		$this->check_ftp_directory($monthly_path);
-		
-		$weekly_path = $this->get_ftp_location("weekly");
-		
-		$this->check_ftp_directory($weekly_path);
-		
-		$daily_path = $this->get_ftp_location("daily");
-		
-		$this->check_ftp_directory($daily_path);
-		
-	} //private function check_ftp_directories()
-
-	/*
-	* 
-	* check_directory
-	*
-	* checks the directory to make sure it exists before we attempt to create the file
-	*
-	* @params string
-	* @access private
-	*/
-	
-	private function check_directory($path)
-	{
-		
-		if(!@opendir($path))
-		{
-			
-			mkdir($path, 0755);	
-			
-		} //if(!@opendir($path))
-		
-		return;
-		
-	} //private function check_directory($path)
-
-	/*
-	* 
-	* check_directories
-	*
-	* checks the directories to make sure they exist before we attempt to create the files
-	*
-	* @access private
-	*/
-	
-	private function check_directories()
-	{
-		
-		//check to make sure the main backup folder exists
-		
-		$this->check_directory($this->base_path.$this->backup_dir);
-		
-		write_file($this->base_path.$this->backup_dir."/.htaccess", "deny from all");
-
-		$quarterly_path = $this->get_file_location("quarterly");
-
-		$this->check_directory($quarterly_path);
-
-		$monthly_path = $this->get_file_location("monthly");
-
-		$this->check_directory($monthly_path);
-		
-		$weekly_path = $this->get_file_location("weekly");
-		
-		$this->check_directory($weekly_path);
-		
-		$daily_path = $this->get_file_location("daily");
-		
-		$this->check_directory($daily_path);
-		
-	} //private function check_directories()	
-
-	/*
-	* 
-	* files_to_keep
-	*
-	* returns an array of all the files that don't need to be deleted
-	*
-	* @params string
-	* @return array
-	* @access private
-	*/
-	
-	private function files_to_keep($type)
-	{
-		
-		$files = array(); //the array that is returned
-		
-		$max = $this->save_info[$type];
-		$i = 1;
-
-		//first we need to check if a monthly backup needs creating or not
-		$map = directory_map($this->get_file_location($type), 1);
-
-		//check to map sure there are some files in the monthly backup directory
-		if(is_array($map) and count($map) > 0)
-		{
-
-			//order the array in reverse so that the newest file will be at the top of the list
-			rsort($map);
-			
-			//loop each of the found files to make sure we have the last file created
-			foreach($map as $key => $file)
-			{
-
-				//checks to make sure the file name is valid
-				$matched = preg_match($this->get_regex($type), $file); 
-				
-				//the filename is valid so now we check the date of this file to see if it is more than one month away				
-				if($matched != false)
-				{
-
-					$files[] = $file;
-					
-					//check to make sure that the file has been uploaded to the FTP server
-					//this will make sure all backups are stored if the FTP upload is activated at a later date
-					if($this->ftp_transfer === true)
-					{
-						
-						$ftp_location = $this->get_ftp_location($type);
-						
-						$list = $this->CI->ftp->list_files($ftp_location);
-						
-						//the file does not appear to be on the server so we will upload it
-						if(!in_array($ftp_location.$file, $list))
-						{
-							
-							$local_location = $this->get_file_location($type);
-							
-							$this->CI->ftp->upload($local_location.$file, $ftp_location.$file, 'auto');
-							echo "Uploading file: ".$ftp_location.$file." to remote server...<br />";
-							
-						}
-						
-					} //if($this->ftp_transfer === true)					
-					
-					if($i >= $max)
-					{
-
-						break;
-					
-					} 
-					else
-					{
-						
-						$i++;	
-						
-					} //if($i == $max)
-					
-				
-				} //if($matched != false)
-			
-			} //foreach($map as $location => $file)
-
-			return $files;
-		
-		} //if(count($map) > 0)					
-		else
-		{
-			
-			return $files;
-		
-		} //if(is_array($map) and count($map) > 0)
-		
-	} //private function files_to_keep($type)
-
-	/*
-	* 
-	* get_regex
-	*
-	* returns the regex that is used to validate the file names
-	*
-	* @params string
-	* @return string
-	* @access private
-	*/
-	
-	private function get_regex($type)
-	{
-
-		return $regex = "^(?:19|20)[0-9]{2}\-[0-1][0-9]\-[0-3][0-9]".$this->file_names[$type]."\.".$this->ext."$^";
-	
-	} //private function get_regex($type)
-
-	/*
-	* 
-	* get_time_difference
-	*
-	* returns a unix timestamp for the selected time period
-	*
-	* @params string
-	* @return int
-	* @access private
-	*/
-			
-	private function get_time_difference($type)
-	{
-		
-		switch($type)
-		{
-			
-			case "quarterly":
-				
-				$date = strtotime("-3 MONTHS");
-			
-				break;
-			
-			case "monthly":
-				
-				$date = strtotime("-1 MONTH");
-			
-				break;
-			
-			case "weekly":
-			
-				$date = strtotime("-1 WEEK");
-			
-				break;
-			
-			default:
-			case "daily":
-			
-				$date = strtotime("-1 DAY");
-			
-				break;
-			
-		} //switch($type)
-		
-		return $date;		
-		
-	} //private function get_time_difference($type)
-
-	/*
-	* 
-	* get_ftp_location
-	*
-	* returns the directory path to the FTP location
-	*
-	* @params string
-	* @return string
-	* @access private
-	*/
-	
-	private function get_ftp_location($type)
-	{
-			
-		return (($this->ftp_base_path == "/" or $this->ftp_base_path == "")? "": "/".$this->ftp_base_path)."/".$this->remote_dir."/".$this->folder_names[$type]."/";	
-		
-	} //private function get_ftp_location($type)
-
-	/*
-	* 
-	* get_file_location
-	*
-	* returns the directory path to the file
-	*
-	* @params string
-	* @return string
-	* @access private
-	*/
-		
-	private function get_file_location($type)
-	{
-		
-		return $this->base_path.$this->backup_dir."/".$this->folder_names[$type]."/";
-		
-	} //private function get_file_location($type)
-
-	/*
-	* 
-	* get_file_name
-	*
-	* returns the filename
-	*
-	* @params string
-	* @return string
-	* @access private
-	*/
-		
-	private function get_file_name($type)
-	{
-		
-		return date('Y-m-d').$this->file_names[$type].".".$this->ext;
-		
-	} //private function get_file_name($type)
-
-	/*
-	* 
-	* get_last_file
-	*
-	* returns the filename that was the last one created
-	*
-	* @params string
-	* @params string
-	* @return string
-	* @access private
-	*/
-	
-	private function get_last_file($location, $type)
-	{
-
-		//first we need to check if a monthly backup needs creating or not
-		$map = directory_map($location, 1);
-				
-		//check to map sure there are some files in the monthly backup directory
-		if(is_array($map) and count($map) > 0)
-		{
-
-			//order the array in reverse so that the newest file will be at the top of the list
-			rsort($map);
-			
-			//loop each of the found files to make sure we have the last file created
-			foreach($map as $key => $file)
-			{
-				
-				//checks to make sure the file name is valid
-				$matched = preg_match($this->get_regex($type), $file); 
-				
-				//the filename is valid so now we check the date of this file to see if it is more than one month away				
-				if($matched != false)
-				{
-
-					return $file;
-				
-				} //if($matched != false)
-			
-			} //foreach($map as $location => $file)
-		
-		} //if(count($map) > 0)		
-		
-	} //private function get_last_file($location, $type)
-			
-	/*
-	* 
-	* remove_old_local_files
-	*
-	* if you have selected to remove the old files this will remove files from the location specified
-	* and keep the files in the array.
-	* Please note that this only scans the top layer of the directory to get the file names.
-	* 
-	* WARNING: if the ftp transfer is enabled then all unexpected files this 
-	* encounters on the ftp server will be removed
-	*
-	* @params string
-	* @params array
-	* @access private
-	*/
-	
-	private function remove_old_local_files($location, $keep = array(), $type)
-	{
-			
-		$map = directory_map($location, 1);
-		
-		//check to make sure there are files in the directory to remove
-		if(is_array($map) and count($map) > 0)
-		{
-
-			if($this->ftp_transfer === true)
-			{
-
-				//get both of these now to save having it get the same value assigned each time the loop
-				//			
-				$ftp_location = $this->get_ftp_location($type);	
-				$list = $this->CI->ftp->list_files($ftp_location);
-			
-			} //if($this->ftp_transfer === true)
-			
-			//loop each file and remove if neccessary
-			foreach($map as $key => $filename)
-			{
-
-				//if the filename is not in the list then remove it from the server
-				if(!in_array($filename, $keep))
-				//if($keep[0] != $filename)
-				{
-					echo "File: ".$location.$filename." removed...<br />";
-					//remove the file from the server
-					@unlink($location.$filename);	
-					
-					//remove the file from the FTP server
-					if($this->ftp_transfer === true)
-					{
-						
-						//the file does not appear to be on the server so we will upload it
-						if(in_array($ftp_location.$filename, $list))
-						{
-							
-							$this->CI->ftp->delete_file($ftp_location.$filename);
-							echo "File: ".$ftp_location.$filename." removed from FTP...<br />";
-							
-						} //if(!in_array($ftp_location.$filename, $list))					
-							
-					} //if($this->ftp_transfer === true)
-					
-				} //if(!in_array($filename, $keep))
-			
-			} //foreach($map as $key => $filename)
-		
-		} //if(is_array($map) and count($map) > 0)
-		
-		return;
-		
-	} //private function remove_old_files()
-
-	/*
-	* 
-	* connect_ftp
-	*
-	* connects the the FTP using the details provided
-	*
-	* @access private
-	*/
-
-	private function connect_ftp()
-	{
-
-		$config['hostname'] = $this->ftp_server;
-		$config['username'] = $this->ftp_user;
-		$config['password'] = $this->ftp_pass;
-		$config['port']     = $this->ftp_port;
-		
-		$this->CI->ftp->connect($config);		
-		
-	}
-	
-} //class Backup
-
-/* End of file backup.php */
-/* Location: ./application/libraries/backup.php */