Getting started

A short introduction on how to install PHPBU, configure PHPBU, and finally execute PHPBU to create a backup.

Download PHPBU

The easiest way to get PHPBU is by downloading the PHAR-Archive

wget https://phar.phpbu.de/phpbu.phar
chmod +x phpbu.phar
php phpbu.phar --version

Create a config file

Use your favorite text editor to create a simple XML PHPBU config file.

The following example should give you a fair impression on what to configure.

<?xml version="1.0" encoding="UTF-8"?>
<phpbu xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:noNamespaceSchemaLocation="http://schema.phpbu.de/5.0/phpbu.xsd">
  <backups>
    <backup name="MyDatabase">
      <!-- source -->
      <source type="mysqldump">
        <option name="databases" value="mydbname"/>
        <option name="user" value="user.name"/>
        <option name="password" value="topsecret"/>
      </source>
      <!-- where should the backup be stored -->
      <target dirname="backup/mysql"
              filename="mysqldump-%Y%m%d-%H%i.sql"
              compress="bzip2"/>
      <!-- check the created backup -->
      <check type="SizeMin" value="10M"/>
      <!-- cleanup the backup location -->
      <!-- as soon as all created backups exceed 500MB remove oldest backups -->
      <cleanup type="Capacity">
        <option name="size" value="500M"/>
      </cleanup>
    </backup>
  </backups>
</phpbu>

Organize your files

Create a backup directory that holds all created backups.

Put the phpbu.xml.dist file in your working directory.

acme/
├── backup/
├── phpbu.phar
└── phpbu.xml.dist

Create your backup

Finally execute the phpbu.phar.

Optionally add arguments like --verbose or --colors for more detailed or colored output.

php phpbu.phar --verbose

If everything works as planned, your output should look like this.

phpbu 5.0.0 by Sebastian Feldmann and contributors

Configuration read from /var/www/acme/phpbu.xml.dist

Time: 44 ms, Memory: 1.00Mb

backup mysql: OK
          | executed | skipped | failed |
----------+----------+---------+--------+
 checks   |        1 |         |      0 |
 syncs    |        0 |       0 |      0 |
 cleanups |        1 |       0 |      0 |
----------+----------+---------+--------+

OK (1 backup, 1 check, 0 syncs, 1 cleanup)

For more detailed information check out the documentation page.