PHP Classes

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

Recommend this page to a friend!
  Info   View files Example   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 50%Total: 469 This week: 1All time: 6,021 This week: 89Up
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: 46
All time rank: 134711 in Hungary Hungary
Week rank: 91 Up2 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  
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  /  lib  
File Role Description
  Plain text file Backup.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:469
This week:1
All time:6,021
This week:89Up
User Ratings User Comments (1)
 All time
Utility:75%StarStarStarStar
Consistency:68%StarStarStarStar
Documentation:-
Examples:62%StarStarStarStar
Tests:-
Videos:-
Overall:50%StarStarStar
Rank:2609
 
Pont ilyet kerestem.
7 years ago (Marton jozsef)
70%StarStarStarStar