Skip to content

Powered by Grav + Helios

Backups

Backups

The backup system in Grav has been completely rewritten for Grav 1.6 to provide more features and functionality. The improvements include:

  • Integration into the new Grav Scheduler to allow for offline backups to run whenever you wish
  • Ability to create multiple backup profiles each with their own set of files, exclude path and file rules, and schedule configuration
  • New auto-purge options based on number, space, or time.
  • New dedicated backups page in the Tools section of the admin plugin.

Configuration

For backwards compatibility, the default configuration mimics the system prior to Grav 1.6, however, it does now have a 5GB limit by default for backup space. You should copy the default configuration file (system/config/backups.yaml) to your `user/config/

Caution

If you use the admin plugin, and save the configuration, the user/config/backups.yaml file will be created automatically.

The default configuration is as follows:

YAML
 1purge:
 2    trigger: space
 3    max_backups_count: 25
 4    max_backups_space: 5
 5    max_backups_time: 365
 6
 7profiles:
 8  -
 9    name: 'Default Site Backup'
10    root: '/'
11    schedule: false
12    schedule_at: '0 3 * * *'
13    exclude_paths: "/backup\r\n/cache\r\n/images\r\n/logs\r\n/tmp"
14    exclude_files: ".DS_Store\r\n.git\r\n.svn\r\n.hg\r\n.idea\r\n.vscode\r\nnode_modules"

Purge

  • space - will purge older backups when you hit the space limit. Controlled by max_backups_space measured in GB
  • time - will purge older backups beyond a number of day. Controlled by max_backups_time measured in days
  • number - will purge older backups beyond a certain number of backups. Controlled by max_backups_count.

Profiles

An array of profiles can be configured. The Default Site Backup profile is configured similarly to the default Grav backup in previous versions. By default, the backup is not automatically processed by the scheduler, but you can set schedule: true and configure the schedule_at: option with a preferred cron expression.

An example of a more complex set of profiles could be:

YAML
 1profiles:
 2  -
 3    name: 'Default Site Backup'
 4    root: /
 5    exclude_paths: "/backup\r\n/cache\r\n/images\r\n/logs\r\n/tmp"
 6    exclude_files: ".DS_Store\r\n.git\r\n.svn\r\n.hg\r\n.idea\r\n.vscode\r\nnode_modules"
 7    schedule: true
 8    schedule_at: '0 4 * * *'
 9  -
10    name: 'Pages Backup'
11    root: 'page://'
12    exclude_files: .git
13    schedule: true
14    schedule_at: '* 3 * * *'

CLI Command

This is covered in more details in the Cli Console -> Grav Command section, but here's an example of running the backup manually:

BASH
cd ~/workspace/portfolio
bin/grav backup

Grav Backup
===========

Choose a backup?
  [0] Default Site Backup
  [1] Pages Backup

Archiving 36 files [===================================================] 100% < 1 sec Done...

 [OK] Backup Successfully Created: /users/joe/workspace/portfolio/backup/pages_backup--20190227120510.zip