PHP Classes

PHP Backup Files to FTP: Send ZIP file with backup of files to a FTP server

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-01-09 (9 months ago) RSS 2.0 feedStarStarStarStar 70%Total: 616 All time: 5,107 This week: 38Up
Version License PHP version Categories
backup-ftp 1.0.9GNU General Publi...5PHP 5, Files and Folders, Systems adm...
Description 

Author

This class can send ZIP file with backup of files to a FTP server.

It creates a temporary ZIP archive with the contents of a list of local files.

The class can send the created ZIP archive to a given FTP server. It can retry sending the file a given number of attempts if it fails for some reason.

After sending the file, the class compares the hash of the local ZIP file with the remote file to determine if it succeeded.

The log of the executed actions displayed and outputted to a log file.

Innovation Award
PHP Programming Innovation award nominee
October 2014
Number 2


Prize: One copy of VS.PHP
All Web sites should have a backup process in place, just in case their information is lost due to incidents that may happen in the future.

It is better to send backup information to a separate machine, so when the site information is lost, the backup information is safe and can be used to recover the lost information.

This class implements an extensive backup solution that can gather several files in a single ZIP file that is sent to another machine using FTP.

It is a robust solution because it can recover from transmission failures. At the end it can verify the integrity of the transmitted file by comparing the hash of its contents with the original file hash.

Manuel Lemos
Picture of Everton da Rosa
  Performance   Level  
Name: Everton da Rosa <contact>
Classes: 17 packages by
Country: Brazil Brazil
Age: 43
All time rank: 78355 in Brazil Brazil
Week rank: 22 Up2 in Brazil Brazil Up
Innovation award
Innovation award
Nominee: 3x

Example

<?php

/*
 * Copyright (C) 2014 Everton
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

/*
 * This file provides a basic example of usage BakFtp class.
 */
require 'bakftp.class.php';

$ftpWrapper = 'ftp://user:secretword@myftpserver.com:21/bakftp/';//In this example, the backup will be saved in bakftp directory server. This directory had to be created beforehand. The class does this automatically to avoid creating directories be randomly giving greater security.

$files = array(
   
'c:/mydir/myfile.txt'
   
,'c:/myotherdir/otherfile.jpg'
);

$bak = new BakFtp('sample', 'c:/users/myuser/desktop/');

$bak->setFtpWrapper($ftpWrapper);

$bak->setFilesToBackup($files);

$bak->backup();


  Files folder image Files (2)  
File Role Description
Plain text file bakftp.class.php Class Class source
Accessible without login Plain text file sample.php Example Example script

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:616
This week:0
All time:5,107
This week:38Up
 User Ratings  
 
 All time
Utility:100%StarStarStarStarStarStar
Consistency:100%StarStarStarStarStarStar
Documentation:-
Examples:100%StarStarStarStarStarStar
Tests:-
Videos:-
Overall:70%StarStarStarStar
Rank:282