PHP Classes

PHP MySQL Remote Backup: Backup MySQL databases to FTP server files

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 50%Total: 471 All time: 6,019 This week: 49Up
Version License PHP version Categories
ftp-backup 1.0Public Domain5.4PHP 5, Databases, Files and Folders, S...
Description 

Author

This class can backup MySQL databases to FTP server files.

It can connect to a given MySQL database server and generates backup files of one or more databases by dumping the database contents as SQL statements that can be used to restore the database tables and their records.

The backup class extends the PHP FTP Client Class and sends the database backup files to a given FTP server.

If the total size of all backup files sent before and the files being sent currently exceeds a given limit, the class can automatically remove old backup files until the total size becomes lower than the limit.

Innovation Award
PHP Programming Innovation award nominee
February 2016
Number 3


Prize: PhpStorm IDE personal permanent license
Backup database data to another machine is a crucial procedure that all sites should have in place, so if anything bad happens, the site database can be restored from a backup.

Many sites take backups using database dumps and send them backup files to another machine via FTP.

The problem with this procedure is that backups tend to pile on the destination machine and take too much space unless there is a regular cleanup procedure.

This class can perform the backup process of a MySQL database and send it to a FTP server. It can automatically delete old files first when they exceed a given total size limit.

Manuel Lemos
Picture of Istvan Dobrentei
  Performance   Level  
Name: Istvan Dobrentei <contact>
Classes: 12 packages by
Country: Hungary Hungary
Age: 47
All time rank: 134511 in Hungary Hungary
Week rank: 180 Up3 in Hungary Hungary Up
Innovation award
Innovation award
Nominee: 9x

Winner: 1x

Example

<?php
require 'vendor/autoload.php';
use
Distvan\Backup;

$config = array(
 
'db_host' => '127.0.0.1', //database host
 
'db_name' => array('database1', 'databas2', 'database3'), //list of databases to dump
 
'db_user' => '', //database username
 
'db_pass' => '', //database password
 
'ftp_host' => 'ftp.domain.com',
 
'ftp_user' => '', //ftp username
 
'ftp_pass' => '', //ftp password
 
'ftp_remote_dir' => 'remote-folder-name',
 
'ftp_local_dir' => 'temp',
 
'max_backup_size' => 4 //Mbyte
);
$backup = new Backup($config);
?>


Details

The class helps to make a multiple database backup and save the compressed dump file to a remote filesystem using ftp. You can set a maximum space and the Backup class checks it and deletes some oldest file to store a new dump when no enough space available on remote ftp folder.


  Files folder image Files (5)  
File Role Description
Files folder imagelib (1 file)
Accessible without login Plain text file .gitignore Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file README.md Data Auxiliary data
Accessible without login Plain text file start.php Example Example script

  Files folder image Files (5)  /  lib  
File Role Description
  Plain text file Backup.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:471
This week:0
All time:6,019
This week:49Up
User Ratings User Comments (1)
 All time
Utility:75%StarStarStarStar
Consistency:68%StarStarStarStar
Documentation:-
Examples:62%StarStarStarStar
Tests:-
Videos:-
Overall:50%StarStarStar
Rank:2671
 
Pont ilyet kerestem.
8 years ago (Marton jozsef)
70%StarStarStarStar