Free Automatic TYPO3 Backup with PHPBU

Category : General

Are you looking for free automatic TYPO3 backup solution? PHPBU is one the famous OpenSource PHP backup solution. Here is the quick TYPO3 PHPBU Backup example.

// .env

 

EMAIL_RECIPIENTS=email
EMAIL_ONLY_ON_ERROR=true

PHPBU_CLEANUP_AMOUNT_LOCAL=5
PHPBU_CLEANUP_AMOUNT_AWS3=5

AWS3_KEY=key
AWS3_SECRET=secret
AWS3_BUCKET=bucket
AWS3_REGION=eu-central-1

SITE_DB_USER=user
SITE_DB_NAME=database
SITE_DB_PASSWORD=password
SITE_DB_PATH_BACKUP_LOCAL=/path/to/local
SITE_DB_PATH_BACKUP_AWS3=/path/to/aws
SITE_CODE_SITE_PATH=/path/to/code
SITE_CODE_PATH_BACKUP_LOCAL=/path/to/local
SITE_CODE_PATH_BACKUP_AWS3=/path/to/aws
SITE_LOGS=/path/to/logs

 

// phpbu.database.json

 

{
    "verbose": true,
    "debug": false,
    "adapters": [
        {
            "type": "dotenv",
            "name": "environment",
            "options": {
                "file": "/path/to/.env"
            }
        }
    ],
    "logging": [
        {
            "type": "json",
            "target": "adapter:environment:SITE_LOGS"
        },
        {
            "type": "mail",
            "options": {
               "transport": "mail",
               "recipients": "adapter:environment:EMAIL_RECIPIENTS",
               "subject": "Server Database-Backup Report",
               "sendOnlyOnError": "adapter:environment:EMAIL_ONLY_ON_ERROR"
            }
        }
    ],
    "backups": [
        {
            "name": "Database",
            "source": {
                "type": "mysqldump",
                "options": {
                    "databases": "adapter:environment:SITE_DB_USER",
                    "user": "adapter:environment:SITE_DB_NAME",
                    "password": "adapter:environment:SITE_DB_PASSWORD"
                }
            },
            "target": {
                "dirname": "adapter:environment:SITE_DB_PATH_BACKUP_LOCAL",
                "filename": "nitsan.in-%Y%m%d-%H%i.sql",
                "compress": "bzip2"
            },
            "syncs": [
                {
                    "type": "amazons3",
                    "options": {
                        "key": "adapter:environment:AWS3_KEY",
                        "secret": "adapter:environment:AWS3_SECRET",
                        "bucket": "adapter:environment:AWS3_BUCKET",
                        "region": "adapter:environment:AWS3_REGION",
                        "path": "adapter:environment:SITE_DB_PATH_BACKUP_AWS3",
                        "useMultiPartUpload": "true",
                        "cleanup.type": "quantity",
                        "cleanup.amount": "adapter:environment:PHPBU_CLEANUP_AMOUNT_AWS3"
                    }
                }
            ],
            "cleanup": {
                "type": "quantity",
                "options": {
                    "amount": "adapter:environment:PHPBU_CLEANUP_AMOUNT_LOCAL"
                }
            }
        }
    ]
}

 

// phpbu.code.json

 

{
    "verbose": true,
    "debug": false,
    "adapters": [
        {
            "type": "dotenv",
            "name": "environment",
            "options": {
                "file": "/path/to/.env"
            }
        }
    ],
    "logging": [
        {
            "type": "json",
            "target": "adapter:environment:SITE_LOGS"
        },
        {
            "type": "mail",
            "options": {
               "transport": "mail",
               "recipients": "adapter:environment:EMAIL_RECIPIENTS",
               "subject": "Server Code-Backup Report",
               "sendOnlyOnError": "adapter:environment:EMAIL_ONLY_ON_ERROR"
            }
        }
    ],
    "backups": [
        {
            "name": "Code",
            "source": {
                "type": "tar",
                "options": {
                    "path": "adapter:environment:SITE_CODE_SITE_PATH"
                }
            },
            "target": {
                "dirname": "adapter:environment:SITE_CODE_PATH_BACKUP_LOCAL",
                "filename": "nitsan.in-%Y%m%d-%H%i",
                "compress": "bzip2"
            },
            "syncs": [
                {
                    "type": "amazons3",
                    "options": {
                        "key": "adapter:environment:AWS3_KEY",
                        "secret": "adapter:environment:AWS3_SECRET",
                        "bucket": "adapter:environment:AWS3_BUCKET",
                        "region": "adapter:environment:AWS3_REGION",
                        "path": "adapter:environment:SITE_CODE_PATH_BACKUP_AWS3",
                        "useMultiPartUpload": "true",
                        "cleanup.type": "quantity",
                        "cleanup.amount": "adapter:environment:PHPBU_CLEANUP_AMOUNT_AWS3"
                    }
                }
            ],
            "cleanup": {
                "type": "quantity",
                "options": {
                    "amount": "adapter:environment:PHPBU_CLEANUP_AMOUNT_LOCAL"
                }
            }
        }
    ]
}

 

// Cron

 

0 1 * * * /usr/local/bin/phpbu --configuration=/path/to/phpbu.database.json
0 1 * * * /usr/local/bin/phpbu --configuration=/path/to/phpbu.code.json

To keep improving, Do you have feedback and suggestions? Or, Are you facing any issues to implement above TYPO3 tutorial? Feel free to write your comment at below comment box; I'll happy to help you :)

Post Comment

Your email address will not be published. Required fields are marked *

×

Name is required!

Enter valid name

Valid email is required!

Enter valid email address

Comment is required!

Google Captcha Is Required!

Be the First to Comment

Stay up to date with our recent TYPO3 Blogs, news, & updates