public/wordpress/wp-content/plugins/backupbuddy/controllers/cron.php
// Copy FTP backup to local backup directory
Copy FTP backup to local backup directory
Copy FTP backup to local backup directory
function _process_ftp_copy( $backup, $ftp_server, $ftp_username, $ftp_password, $ftp_directory, $port = '21', $ftps = '0' ) {
		pb_backupbuddy::set_greedy_script_limits();
		if ( ! class_exists( 'backupbuddy_core' ) ) {
			require_once( pb_backupbuddy::plugin_path() . '/classes/core.php' );
		}
		if ( $ftps == '1' ) { 
			if ( function_exists( 'ftp_ssl_connect' ) ) {
				$conn_id = ftp_ssl_connect( $ftp_server, $port );
				if ( $conn_id === false ) {
					pb_backupbuddy::status( 'details',  'Unable to connect to FTPS  (check address/FTPS support).', 'error' );
					return false;
				} else {
					pb_backupbuddy::status( 'details',  'Connected to FTPs.' );
				}
			} else {
				pb_backupbuddy::status( 'details',  'Your web server doesnt support FTPS in PHP.', 'error' );
				return false;
			}
		} else { 
			if ( function_exists( 'ftp_connect' ) ) {
				$conn_id = ftp_connect( $ftp_server, $port );
				if ( $conn_id === false ) {
					pb_backupbuddy::status( 'details',  'ERROR: Unable to connect to FTP (check address).', 'error' );
					return false;
				} else {
					pb_backupbuddy::status( 'details',  'Connected to FTP.' );
				}
			} else {
				pb_backupbuddy::status( 'details',  'Your web server doesnt support FTP in PHP.', 'error' );
				return false;
			}
		}
		$login_result = ftp_login( $conn_id, $ftp_username, $ftp_password );
		$destination_file = backupbuddy_core::getBackupDirectory() . $backup;
		if ( file_exists( $destination_file ) ) {
			$destination_file = str_replace( 'backup-', 'backup_copy_' . pb_backupbuddy::random_string( 5 ) . '-', $destination_file );
		}
		if ( ftp_get( $conn_id, $destination_file, $ftp_directory . $backup, FTP_BINARY ) ) {
		    pb_backupbuddy::status( 'message', 'Successfully wrote remote file locally to `' . $destination_file . '`.' );
		} else {
		    pb_backupbuddy::status( 'error', 'Error writing remote file locally to `' . $destination_file . '`.' );
		}
		ftp_close( $conn_id );
	}
function _process_ftp_copy ( $ backup , $ ftp_server , $ ftp_username , $ ftp_password , $ ftp_directory , $ port = '21' , $ ftps = '0' ) { pb_backupbuddy :: set_greedy_script_limits ( ) ; if ( ! class_exists ( 'backupbuddy_core' ) ) { require_once ( pb_backupbuddy :: plugin_path ( ) . '/classes/core.php' ) ; } if ( $ ftps == '1' ) { if ( function_exists ( 'ftp_ssl_connect' ) ) { $ conn_id = ftp_ssl_connect ( $ ftp_server , $ port ) ; if ( $ conn_id === false ) { pb_backupbuddy :: status ( 'details' , 'Unable to connect to FTPS  (check address/FTPS support).' , 'error' ) ; return false ; } else { pb_backupbuddy :: status ( 'details' , 'Connected to FTPs.' ) ; } } else { pb_backupbuddy :: status ( 'details' , 'Your web server doesnt support FTPS in PHP.' , 'error' ) ; return false ; } } else { if ( function_exists ( 'ftp_connect' ) ) { $ conn_id = ftp_connect ( $ ftp_server , $ port ) ; if ( $ conn_id === false ) { pb_backupbuddy :: status ( 'details' , 'ERROR: Unable to connect to FTP (check address).' , 'error' ) ; return false ; } else { pb_backupbuddy :: status ( 'details' , 'Connected to FTP.' ) ; } } else { pb_backupbuddy :: status ( 'details' , 'Your web server doesnt support FTP in PHP.' , 'error' ) ; return false ; } } $ login_result = ftp_login ( $ conn_id , $ ftp_username , $ ftp_password ) ; $ destination_file = backupbuddy_core :: getBackupDirectory ( ) . $ backup ; if ( file_exists ( $ destination_file ) ) { $ destination_file = str_replace ( 'backup-' , 'backup_copy_' . pb_backupbuddy :: random_string ( 5 ) . '-' , $ destination_file ) ; } if ( ftp_get ( $ conn_id , $ destination_file , $ ftp_directory . $ backup , FTP_BINARY ) ) { pb_backupbuddy :: status ( 'message' , 'Successfully wrote remote file locally to `' . $ destination_file . '`.' ) ; } else { pb_backupbuddy :: status ( 'error' , 'Error writing remote file locally to `' . $ destination_file . '`.' ) ; } ftp_close ( $ conn_id ) ; }
Copy FTP backup to local backup directory
Copy FTP backup to local backup directory
// Connect to server. // Connect with FTPs. // Connect with FTP (normal). // login with username and password // try to download $server_file and save to $local_file // close this connection