Backups

BackupManager creates database dumps (mysqldump) and uploads archives (tar.gz). Backups can be stored locally or on S3, and optionally encrypted with Laravel's Crypt. Restore uses prepareBackupForRestore to download/decrypt before applying.

Flow

flowchart LR subgraph create [Create] DB[backupDatabase] UP[backupUploads] DB --> process UP --> process process[processBackup] process --> store[(local or S3)] end subgraph restore [Restore] get[prepareBackupForRestore] get --> mysql[mysql restore] get --> tar[tar extract] end

Types

Key file

app/Services/Backups/BackupManager.php

Scheduling

In routes/console.php:

Config

KeyPurpose
wphoster.backups.retention_daysHow long to keep backups (default 14)
wphoster.backups.storage_disklocal or s3
wphoster.backups.encryptEncrypt backup content with Laravel Crypt
wphoster.backups.verify_after_backupRun verify after each backup

Restore snippet

// Database: prepare path (download/decrypt), then mysql
$restorePath = $this->prepareBackupForRestore($backup);
$this->runner->run(['bash', '-c', "mysql ... < " . escapeshellarg($restorePath)], null, ['MYSQL_PWD' => $password]);

// Uploads: tar -xzf into wp-content/uploads
$this->runner->run(['tar', '-xzf', $restorePath, '-C', $uploadsPath]);