Skip to content

Configuration

phil/backup-bundle

Every key of phil_backup, with its default:

phil_backup:
    connection: database_connection             # a Doctrine DBAL connection service
    directory: '%kernel.project_dir%/var/backup'
    binaries: {}                                # { pg_dump: /usr/lib/postgresql/17/bin/pg_dump }
    timeout: null                               # seconds; null, no limit
    key: null                                   # '%env(PHIL_BACKUP_KEY)%'; required unless allow_unencrypted
    allow_unencrypted: false                    # true, backups without a key are written in clear; with a key, older ones in clear are read
    media: {}                                   # { uploads: '%kernel.project_dir%/public/uploads' }
    rotation: { last: 0, daily: 0, weekly: 0, monthly: 0 }
    restore:
        production_environments: [prod]
        keep_before_restore: 3
    verify:
        database: null                          # the scratch database of a server's restore test
KeyTypeDefaultEffect
connectionnon-empty stringdatabase_connectionService id of the Doctrine DBAL connection backed up and restored; its platform chooses the client, its parameters give the credentials.
directorynon-empty string%kernel.project_dir%/var/backupWhere sets are written and found, created 0700.
binariesmap of tool name to path{}Paths of client tools that are not on the PATH.
timeoutfloat or nullnullSeconds a client tool may run.
keystring or nullnullThe backup key, 32 random bytes in base64; read when a command first needs it, so an environment variable works. Required unless allow_unencrypted is true.
allow_unencryptedbooleanfalseWhether backups may be written in clear when key is null. A key, when given, is always used, and a backup in clear is then refused by phil:backup:restore and phil:backup:verify — anyone able to write to the backup storage could have put it there — unless this is true, for the backups written before the key.
mediamap of name to directory{}Media directories backed up beside the database, each by a name of letters, digits, - and _.
rotation.last, daily, weekly, monthlyintegers, 0 or more0How many sets each rule keeps after each phil:backup:create; all zero, every set is kept. See phil/backup's rotation (doc/rotation.md of that package).
restore.production_environmentslist of strings[prod]Kernel environments in which a restore needs PHIL_BACKUP_ALLOW_PRODUCTION_RESTORE; see restore-protection.md.
restore.keep_before_restoreinteger, 1 or more3How many sets labelled before-restore are kept once a restore succeeds; the older ones are removed.
verify.databasestring or nullnullThe scratch database, on the same server, into which phil:backup:verify restores a MySQL, MariaDB or PostgreSQL backup; null, it is not restored.

Services

Service idClassVisibilityDefinition
Phil\BackupBundle\Infrastructure\Process\ProcessCommandRunner—privateFrom binaries and timeout.
phil_backup.database_clientDatabaseClientprivateBuilt by DatabaseClients::forConnection() from connection and the runner (PhilBackupBundle::DATABASE_CLIENT).
Phil\Backup\Storage\BackupDirectory, Phil\Backup\Media\MediaArchive—privateFrom directory and media.
Phil\Backup\Encryption\BackupKey, BackupCipher—privateOnly with a key: BackupKey::fromBase64() of the key, and the cipher over it.
Phil\Backup\Rotation\RotationPolicy—privateOnly when a rule is above zero.
Phil\Backup\Restore\RestoreGuard—privateFrom %kernel.environment% and restore.production_environments.
Phil\Backup\Backups—publicOver the client, the directory, the cipher or null, the media archive and the rotation or null.
CreateBackupCommand, RestoreBackupCommand, VerifyBackupCommand—privatephil:backup:create, phil:backup:restore, phil:backup:verify; the restore with restore.keep_before_restore, the last with verify.database.

Nothing connects to the database while the container is built or the client created: the platform comes from the connection's parameters, or from the server version they give.

Build-time validation

The Config component refuses an empty connection or directory, an empty media directory, a negative rotation count and a keep_before_restore below 1. A backup holds every person's data, so a configuration without a key is refused unless it says otherwise:

Invalid configuration for path "phil_backup": Backups are encrypted: give phil_backup.key, or set phil_backup.allow_unencrypted to true to write them in clear.

The extension builds the media archive once while loading, so a bad media name fails the container build rather than the first backup:

phil_backup.media: The media name "up loads" holds characters other than letters, digits, "-" and "_".

A key that is not 32 bytes of base64 is refused when a command first builds Backups, with A backup key is 32 random bytes in base64, such as the output of base64_encode(random_bytes(32)).