Skip to main content
Version: v8.x

Backups

phpvms backs up files and the database via spatie/laravel-backup. Disabled by default — enable it to start nightly snapshots.

Backups run nightly. The oldest is rotated out so you keep a rolling window (last night, the night before, etc).

warning

Backups can consume a large amount of data and disk space

Basic Configuration

With this configuration, a backup will be added to the storage/app/{yourApplicationName} folder every day. You will receive a notification in case of failure at the email address you specify.

.env
BACKUP_ENABLED=true
BACKUP_NOTIFICATIONS_MAIL_TO=yourEmail@example.com

For this feature to work, you need to have email configured (see here).

Advanced Configuration

Notifications

By default, only failure notifications are sent via email. You can choose to receive success notifications as well and send them to Discord.

.env
BACKUP_FAILED_NOTIFICATIONS_CHANNELS=mail
BACKUP_SUCCEED_NOTIFICATIONS_CHANNELS=mail,discord
# The following line shouldn't be added again if you already added it in the basic configuration
BACKUP_NOTIFICATIONS_MAIL_TO=yourEmail@example.com
BACKUP_DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/...

If you choose the mail channel, you need to configure BACKUP_NOTIFICATIONS_MAIL_TO with the email where you want to receive notifications.

If you choose the discord channel, you need to configure BACKUP_DISCORD_WEBHOOK_URL with the webhook URL where you want to receive notifications. See Notifications to create a webhook.

Disks

By default, backups are only made on the local disk corresponding to the /storage/app/{yourApplicationName} folder. You can add other disks to send your backups.

.env
BACKUP_DISKS=local,r2

To use a remote disk like Amazon S3, CloudFlare R2 or SFTP, you must configure the details in .env properly. By default phpvms v7 supports Amazon S3, CloudFlare R2 and SFTP. As an example; To use CloudFlare R2, a bucket should be configured in your account along with an S3 compatible API and below details should be in your .env file

.env
CLOUDFLARE_R2_BUCKET=''
CLOUDFLARE_R2_ENDPOINT=''
CLOUDFLARE_R2_ACCESS_KEY_ID=''
CLOUDFLARE_R2_SECRET_ACCESS_KEY=''

Also it is possible to add more disks to support different file systems, you need to create the disk in config/filesystems.php. Examples of configuring disks can be found in Laravel Documents and other online sources.

Backup Retention Configuration

By default, phpvms keeps backups for the last 7 days and retains a maximum of 5000 MB of backup data. You can adjust these settings to customize the retention period and maximum size.

To change the number of days for which backups are kept, set the BACKUP_MAX_DAYS variable in your .env file. For example, to keep backups for 3 days, add the following line:

.env
BACKUP_MAX_DAYS=3

To change the maximum size of backups retained, set the BACKUP_MAX_SIZE variable in your .env file. The size is specified in megabytes. For example, to retain backups up to 10000 MB in size, add the following line:

.env
BACKUP_MAX_SIZE=10000

Encryption

Encrypt backups with AES256 and a password:

.env
BACKUP_ARCHIVE_PASSWORD=yourPassword

Need help?

Stuck on something or want to share what you've built? The community is active on the forum and GitHub.