It's best practice to not store all you backups locally or not only storing them locally. With PHPBU you can copy your backups to different locations.
If you are syncing your backup to a cloud service it's advised to encrypt your backup beforehand. Especially if your backup contains personal identifiable information.
Table 8.1. Supported types of syncs:
Type | Description |
---|---|
amazon | Copy your backup to your amazon s3 account. |
copy.com | Copy your backup to a copy account. |
dropbox | Copy your backup to a dropbox account. |
rsync | Sync your backups with rsync. |
sftp | Copy your backup to a server via SFTP. |
SoftLayer Object Storage | Sync your backup to a Softlayer Object Storage account. |
Sync your backup to an amazon S3 account.
If you are not using the PHAR Version you have to require "aws/aws-sdk-php": "2.7.*"
in your composer file.
Table 8.2. amazons3-Options
Name | Value | Required | Default | Description |
---|---|---|---|---|
key | string | yes | - | The amazon s3 key. |
secret | string | yes | - | The amazon S3 secret. |
bucket | string | yes | - | A bucket where to store the backup. |
region | string | yes | - | The region where the bucket is located e.g. 'eu-central-1'. |
path | string | no | / | Path where to store the backup in your bucket. |
useMultiPartUpload | boolean | no | false | Use Amazon S3 MultiPartUpload functionality. |
Example 8.1: amazons3 XML example
<!-- sync amazon s3 --> <sync type="amazons3"> <option name="key" value="myAwsKey"/> <option name="secret" value="myAwsSecret"/> <option name="bucket" value="backup"/> <option name="region" value="eu-central-1"/> <option name="path" value="/some/dir"/> </sync>
Example 8.2: amazons3 JSON example
{ "type": "amazons3", "options": { "key": "myAwsKey", "secret": "myAwsSecret", "bucket": "backup", "region": "eu-central-1", "path": "/some/dir", "useMultiPartUpload": "true" } }
Sync your backup to a dropbox account.
If you are not using the PHAR Version you have to require
"dropbox/dropbox-sdk": "1.1.*"
in your composer file.
Table 8.3. dropbox-Options
Name | Value | Required | Default | Description |
---|---|---|---|---|
token | string | yes | - | The dropbox authentication token. Go to www.dropbox.com/developers/apps Create your app Choose: dropbox api app files and datastore yes provide some app name "my-dropbox-app" generate access token to authenticate connection to your dropbox |
path | string | yes | - | Directory where to store the backup in your dropbox account. |
Example 8.3: dropbox XML example
<!-- sync dropbox --> <sync type="dropbox"> <option name="token" value="myCrazyLongApiTokenThatIGotFromDropbox"/> <option name="path" value="/some/dir"/> </sync> </section>
Example 8.4: dropbox JSON example
{ "type": "dropbox", "options": { "token": "myCrazyLongApiTokenThatIGotFromDropbox", "path": "/some/dir" } }
Sync your backup via the rsync command.
Table 8.4. rsync-Options
Name | Value | Required | Default | Description |
---|---|---|---|---|
path | string | yes | - | The remote path where your backups should be synced to. |
host | string | yes | - | The remote host where your backups should be synced to. |
user | string | no | OS-User | The user to connect to the remote host. Make sure the user is able to connect without entering a password otherwise you get prompted for a password while executing phpbu. |
dirsync | boolean | no | false | Sync the target directory instead of syncing only the target file. |
delete | boolean | no | false | Add the --delete option to the rsync call, so locally deleted files will be deleted remotely as well. |
exclude | string | no | - | List of files to exclude from the sync separated by ":" e.g. "*.suffix:foo.bar". |
args | string | no | - | Advanced mode to use completely custom options. "rsync {args}". WARNING: phpbu is not escaping this in any way so use with caution! Use %TARGET_FILE% and %TARGET_DIR% as reference to your created backup. |
Example 8.5: rsync XML example
<!-- sync rsync --> <sync type="rsync"> <option name="path" value="/backup/some/path"/> <option name="dirsync" value="true"/> <option name="host" value="backup.example.com"/> <option name="user" value="backup"/> </sync>
Example 8.6: rsync JSON example
{ "type": "rsync", "options": { "path": "/backup/some/path", "dirsync": "true", "host": "backup.example.com", "user": "backup" } }
Copy your backup to another server via SFTP or FTP.
If you want to use SFTP and you are not using the PHAR version you have to require
"phpseclib/phpseclib": "2.0.*@dev"
in your composer file.
For this to work you have to set the minimum-stability
to dev
.
If you want to use the FTP-Sync your PHP has to be compiled with --enable-ftp
.
Table 8.5. (s)ftp-Options
Name | Value | Required | Default | Description |
---|---|---|---|---|
host | string | yes | - | The host you want do copy your backups to. |
user | string | yes | - | The user you want to connect with. |
password | string | no | - | The password to authenticate the user. |
path | string | yes | - | The remote path where to copy the backup. |
Example 8.7: sftp XML example
<!-- sync sftp --> <sync type="sftp"> <option name="host" value="backup.example.com"/> <option name="user" value="user.name"/> <option name="password" value="topsecret"/> <option name="path" value="backup/someName"/> </sync>
Example 8.8: sftp JSON example
{ "type": "sftp", "options": { "host": "backup.example.com", "user": "user.name", "password": "topsecret", "path": "backup/someName" } }
If you want to use plain FTP just use ftp
as type, options stay the same.
Sync your backup to a Softlayer account.
If you are not using the PHAR Version you have to require
"softlayer/objectstorage": "dev-master"
in your composer file.
For this to work you have to set the minimum-stability
to dev
.
Table 8.6. softlayer-Options
Name | Value | Required | Default | Description |
---|---|---|---|---|
user | string | yes | - | The user you want to connect with. |
secret | string | no | - | The api key to authenticate the user. |
host | string | yes | - | The host you want do copy your backups to. |
container | string | yes | - | The Object Storage Container where to put the backup. |
path | string | yes | - | The remote path where to copy the backup. |
Example 8.9: softlayer XML example
<!-- sync softlayer object storage --> <sync type="softlayer"> <option name="user" value="user.name"/> <option name="secret" value="topsecret"/> <option name="host" value="some.softlayer.domain.com"/> <option name="container" value="backup"/> <option name="path" value="/backup/someName"/> </sync>
Example 8.10: softlayer JSON example
{ "type": "softlayer", "options": { "user": "user.name", "secret": "topsecret", "host": "some.softlayer.domain.com", "container": "backup", "path": "/backup/someName" } }