Thread: Administrative and Maintenance Tools - vB Database Backup Pro (Lite) for vb 3.6
View Single Post
  #325  
Old 06-12-2007, 03:27 PM
Deimos Deimos is offline
 
Join Date: Oct 2002
Posts: 529
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Because I do more than one backup a day, I changed the file saving format, so it saves it by year/month/day/hour/minute

So in mysqlbackupconfig.php, on the line which reads..

$backup['DATE']

I changed it to

Code:
$backup['DATE'] = 'Y-m-d-G-i';  // Backup file date format
To add remote server backup ability, my coder added this in the mysqlbackup.php file

Below this:

Code:
			// Unlock Tables
			if ($this->LOCK)
			{
				$this->MYSQL->query($unlock);
			}
		}
	}
Add this:

Code:
	/* ------------- Remote FTP backup - added 6.11.07 ------ */
	
	//If you want to move or replicate the folder hierarchy from your current server to another remote server. Then this will be helpful as this will browse the current server's directory and at the same time it will copy that file in the remote server in the same directory.

//This script will copy all the files from this directory and subdirectory to another remote server via FTP
// Source: http://us2.php.net/ftp

function remoteBackup() {

function rec_copy ($source_path, $destination_path, $con)
{
    ftp_mkdir($con, $destination_path);
    ftp_site($con, 'CHMOD 0777 '.$destination_path);
    ftp_chdir($con,$destination_path);

    if (is_dir($source_path))
    {
        chdir($source_path);
        $handle=opendir('.');
        while (($file = readdir($handle))!==false)
        {
            if (($file != ".") && ($file != ".."))
            {
                if (is_dir($file))
                {
                    // choose only the current backup folder
	if($file != "propertyimages")
                    {
                        rec_copy ($source_path."/".$file, $file, $con);
                        chdir($source_path);
                        ftp_cdup($con);
                    }
                }
                if (is_file($file))
                {
                    $fp = fopen($file,"r");
                    // this will convert spaces to '_' so that it will not throw error.  -- VK
                    ftp_fput ($con, str_replace(" ", "_", $file), $fp,FTP_BINARY);
                    ftp_site($con, 'CHMOD 0755 '.str_replace(" ", "_", $file));
                }
            }
        }
        closedir($handle);
    }
}

// make a FTP connection********************************** ADAM CHANGE THESE 2 LINES *********************************************************************************
$con = ftp_connect("XX.XX.XX.XX",21);
$login_result = ftp_login($con,"USERNAME","PASSWORD");   

// this is the root path for the remote server ******************** 
$rootpath = "/";   

// this is the physical path of the source directory. actually u can also use the relative path. -- VK
$sourcepath = realpath("/XXXX/XXXX/XXXX");

// this directory name will only change the top most directory and not the inner one -- VK
$destination_dir_name = "XXXX/";

rec_copy ($sourcepath, $destination_dir_name, $con);
if (function_exists("ftp_close"))
{
    ftp_close($con);
}

}
/* -------------- END FTP Remote Backup ----------------------*/
You need to change the "USERNAME" and "PASSWORD" bit
Additionally, you need to set the correct IP/hostname and the paths.

So far for me, it's working a treat
I've got it running every 3 hours to backup my database, gzip it, then ftp it to the server.

Note: You will get a warning when the backup completes that the destination directory already exists
I haven't fixed that bit yet
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01175 seconds
  • Memory Usage 1,784KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete