Skip to content

kelvinj/php_backup_s3

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 

Repository files navigation

Credits

Original source: github.com/ianneub/php_backup_s3/tree

phpBackupS3

This program will backup file paths and MySQL databases to Amazon's S3 storage cloud service.

I've used this program in production for about a year with no problems. But, your results may vary.

Features

  • Simple to use
  • Backups all databases on a MySQL server
  • Backups and compresses (using bzip2) directories and files
  • Uses URL type storage keys, so it's easy to browse the backup bucket
  • (optionally) Removes old backups according to a grandfather-father-son based schedule

Installation

  1. Copy the backup.dist.php file to a new file name, like backup.php
  2. Add your Amazon AWS access key and password in the backup.php file provided.
  3. Customize the files and database servers that are backed up.
  4. Upload to your server.
  5. Setup a cronjob to run the backups for you!

For example, create a file called /etc/cron.daily/backup and add this code to it:

#!/bin/bash
/usr/bin/php /path/to/script/backup.php    
exit 0

NOTE: Make sure to set the /etc/cron.daily/backup file to be executable. Like this:

chmod +x /etc/cron.daily/backup

About this script

This set of scripts ships with three files:

  • backup.php--This is an example of how to call the backup functions
  • include/
    • backup.inc.php--All the backup functions are in here
    • S3.php--This is the library to access Amazon S3

(optional) Backup deletion schedule

A unique feature of this script is the way it will store (and eventually delete) old backups to conserve space, and yet maintain significant backup history. In this method you will have the following full backups:

  • Everyday for the past two weeks (14 backups)
  • Every saturday for the past 2 months (8 or 9 backups)
  • First day of the month going back forever

This allows you to keep a very detailed history of your files during the most recent time, but progressively remove backups as time goes on to save space. This feature can be turned off if you want to store all your backups, all the time.

To disable this feature, comment out the following line from backup.inc.php:

deleteBackups($BACKUP_BUCKET);

Requirements

About the author

My name is Ian. I wrote this small program to help backup my virtual machines hosted at various places. I figured someone might be able to make use of it, so I've published it as open source. I also wanted a way to store my version history, learn to use git, and do it for free. Thanks github!

ToDo

  • Add configuration documentation
  • Comment code

About

Backup files and MySQL databases to S3 using PHP.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%