While working on two servers, we can take the backup of database on one server using mysqldump command in php.
exec(‘mysqldump –host ‘.$dbhost.’ –user ‘.$dbuser.’ –password=’.$dbpass.” “. $dbname.’ > ‘.$dbname.’.sql’);
After creating dump of database, user can move the dump database file from one server to another using FTP(FILE TRANSFER PROTOCOL). Following are the FTP steps to take backup from one server to another :
1. ftp_connect : Firstly We have to connect with ftp using hostname.
2. ftp_login : Then we have to login using connect we created using ftp_connect.
3. ftp_put : This method is used to move the file from one server to another.
4. ftp_get : This method is used to get the file from another server.
5. ftp_close : At Last, close the Connection.