Skip to content

sevensource/magnolia-module-simple-backup

Repository files navigation

Magnolia module SimpleBackup

GitHub Tag Maven Central License

Magnolia CMS module adding backup and restore functionality

Demo

See simple-backup-demo-module and simple-backup-demo-scripts for a fully functional demo.

Installation

The module is available on Maven central - add it to your war file:

<dependency>
  <groupId>org.sevensource.magnolia</groupId>
  <artifactId>magnolia-module-simple-backup</artifactId>
  <version>${magnolia-module-simple-backup.version}</version>
</dependency>

Configuration

  • Module configuration is done in Magnolias config workspace in /modules/simplebackup/config
  • add a backup job definition beneith /modules/simplebackup/config/configurations:
    example:
      backupPath: "/var/mgnl-backup"  # base path where backups are stored
      enabled: true                   # will only be executed if set to true
      name: example                   # name of the job
      workspaces:                     # a list of workspaces to backup
        website:
          workspace: website          # name of the workspace
          path: /                     # root path within the workspace to backup
          split: true                 # if true, a new file will be written for every subfolder
        config:
          workspace: config
          path: /
          split: false

Execution

Backup and Restore is triggered via Magnolia Commands Available commands:

Catalog Command Parameters Description
simplebackup backup configuration => name of configured backup job Triggers the execution of a backup job with the name specified in configuration
simplebackup restore path => path to the directory that contains the backup files Triggers the execution of a restore
simplebackup garbage-collection none Triggers the execution of a JackRabbit Repository Garbage Collection

Executing backups from Java/Groovy

map  = new java.util.HashMap<String, String>()
map.put("configuration", "example")        // name of the backup job created above
map.put("backup-subdirectory", "nightly")  // optional parameter, if omitted a timestamp will be used
cm = info.magnolia.commands.CommandsManager.getInstance()
cm.executeCommand('simplebackup','backup',map)

Executing restores from Java/Groovy

map  = new java.util.HashMap<String, String>()
map.put("path", "/var/magnolia-backups/author/2020-01-25T120000") // path to the directory in which the backup files are stored
cm = info.magnolia.commands.CommandsManager.getInstance()
cm.executeCommand('simplebackup','restore',map)

Executing garbage collections from Java/Groovy

cm = info.magnolia.commands.CommandsManager.getInstance()
cm.executeCommand('simplebackup','garbage-collection', null)

via Magnolia's scheduler

Using Magnolia Scheduler Module, regular backups can be executed - see Commands-Scheduling for details.

via REST services

Using Magnolia Rest Module backups can be initiated via the REST API:

  • enable the backup command in /modules/rest-services/rest-endpoints/commands/enabledCommands:

config.modules.rest-services.rest-endpoints.commands.enabledCommands.backup.yaml

backup:
  catalogName: simplebackup
  commandName: backup
  access:
    roles:
      rest: rest-editor