protected function BackupMigrateDestinationSFTP::sftpConnect in Backup and Migrate SFTP 7
Same name and namespace in other branches
- 6 destinations.sftp.inc \BackupMigrateDestinationSFTP::sftpConnect()
Connect to the remote server.
4 calls to BackupMigrateDestinationSFTP::sftpConnect()
- BackupMigrateDestinationSFTP::load_file in ./
destinations.sftp.inc - Download a remote file to the local server.
- BackupMigrateDestinationSFTP::_delete_file in ./
destinations.sftp.inc - Delete a remote file.
- BackupMigrateDestinationSFTP::_list_files in ./
destinations.sftp.inc - List the files in the remote server.
- BackupMigrateDestinationSFTP::_save_file in ./
destinations.sftp.inc - Save a local file to the remote server.
File
- ./
destinations.sftp.inc, line 154 - Functions to handle the SFTP backup destination.
Class
- BackupMigrateDestinationSFTP
- A destination for sending database backups to an SFTP server.
Code
protected function sftpConnect() {
$host = $this->dest_url['host'];
$port = !empty($this->dest_url['port']) ? $this->dest_url['port'] : 22;
$this->connection = @ssh2_connect($host, $port);
if (!$this->connection) {
throw new Exception("Could not connect to {$host} on port {$port}.");
return FALSE;
}
$user = $this->dest_url['user'];
$pass = $this->dest_url['pass'];
if (!@ssh2_auth_password($this->connection, $user, $pass)) {
throw new Exception("Could not authenticate with username {$username} " . "and password {$password}.");
return FALSE;
}
$this->sftp = @ssh2_sftp($this->connection);
if (!$this->sftp) {
throw new Exception("Could not initialize SFTP subsystem.");
return FALSE;
}
return TRUE;
}