Backups

Usage

System

Skipper runs automated system backups on a daily basis (by default).

Each backup captures:

  • Databases
  • Files (Public / Private / Temporary)

The frequency of these system backups can be configured in the projects configuration.

$ cat .skpr/defaults.yml

...

backup:
  schedule: @daily # Crontab format.

Note

crontab guru is a great resource for writing Crontabs.

On Demand

Developers can execute backups ondemand eg. prior to executing a deployment.

$ skpr backup create dev
Creating new backup for dev
Backup dev-g7rzr completed in 7s

Using a Tag

Additionally developers can provide the flag --tag to group backups.

This becomes convenient when grouping backups with common tasks eg. --tag=predeploy.

$ skpr backup create dev --tag=test

Restore

Skpr automatically mounts the restic repository when shelling into an environment. This means you are able to dump and rsync any files from the backup directly. Or you can use the skpr cli to restore an entire backup directly to an environment.

Shell

Backups are accessible as a mounted filesystem when running the shell or exec commands.

Start a shell session

$ skpr shell dev
skpr@drupal-dev-exec-kjkrl:data $

Browse to backups

skpr@drupal-dev-exec-jldxs:data $ ls -l /mnt/backups/
total 0
dr-xr-xr-x    1 skpr     skpr             0 Jun 20 01:50 hosts
dr-xr-xr-x    1 skpr     skpr             0 Jun 20 01:50 ids
dr-xr-xr-x    1 skpr     skpr             0 Jun 20 01:50 snapshots
dr-xr-xr-x    1 skpr     skpr             0 Jun 20 01:50 tags

Inspect tagged backups

skpr@drupal-dev-exec-jldxs:data $ ls -l /mnt/backups/tags/test/
total 0
dr-xr-xr-x    4 skpr     skpr             0 Jun 20 03:08 2019-06-20T03:08:05Z
dr-xr-xr-x    4 skpr     skpr             0 Jun 20 03:10 2019-06-20T03:10:12Z
lrwxrwxrwx    1 skpr     skpr             0 Jun 20 03:10 latest -> 2019-06-20T03:10:12Z

Dump a file

skpr@drupal-dev-exec-jldxs:data $ restic dump --quiet latest /mysql/default.sql > /tmp/default.sql

CLI

Backups can be restored directly from the skpr cli to any environment.

List backups

$ skpr backup list
 ─────────── ──────────── ─────────────────────── ───────────────────── ───────────────────── ────────── ───────────
  NAME (6)    PHASE        TAGS                    START TIME            COMPLETION TIME       DURATION   RESTIC ID
 ─────────── ──────────── ─────────────────────── ───────────────────── ───────────────────── ────────── ───────────
  dev-xjrrk   InProgress   dev, ondemand, mytag2   2019/09/05 23:21:35
  dev-kzwpq   Completed    dev, ondemand, mytag    2019/09/05 23:16:15   2019/09/05 23:16:22   7s         b57dc5cf
  dev-vwllx   Completed    dev, ondemand           2019/09/05 23:15:41   2019/09/05 23:15:47   6s         f0b3aecb
  dev-5fkzk   Completed    dev, ondemand           2019/09/05 23:15:24   2019/09/05 23:15:33   9s         79a31f29
  dev-rvngt   Completed    dev, ondemand           2019/09/05 23:10:38   2019/09/05 23:10:48   10s        06c257cd
  dev-cntnj   Completed    dev, ondemand           2019/09/05 23:03:46   2019/09/05 23:07:06   3m20s      0c17a1df
 ─────────── ──────────── ─────────────────────── ───────────────────── ───────────────────── ────────── ───────────

You can also list backups by one or more tags.

$ skpr2 backup list --tag mytag
  ─────────── ─────────── ────────────────────── ───────────────────── ───────────────────── ────────── ───────────
   NAME        PHASE       TAGS                   START TIME            COMPLETION TIME       DURATION   RESTIC ID
  ─────────── ─────────── ────────────────────── ───────────────────── ───────────────────── ────────── ───────────
   dev-kzwpq   Completed   dev, ondemand, mytag   2019/09/05 23:16:15   2019/09/05 23:16:22   7s         b57dc5cf
  ─────────── ─────────── ────────────────────── ───────────────────── ───────────────────── ────────── ───────────

$ skpr2 backup list --tag mytag --tag mytag2
 ─────────── ─────────── ─────────────────────── ───────────────────── ───────────────────── ────────── ───────────
  NAME        PHASE       TAGS                    START TIME            COMPLETION TIME       DURATION   RESTIC ID
 ─────────── ─────────── ─────────────────────── ───────────────────── ───────────────────── ────────── ───────────
  dev-xjrrk   Completed   dev, ondemand, mytag2   2019/09/05 23:21:35   2019/09/05 23:21:45   10s        1179ea28
  dev-kzwpq   Completed   dev, ondemand, mytag    2019/09/05 23:16:15   2019/09/05 23:16:22   7s         b57dc5cf
 ─────────── ─────────── ─────────────────────── ───────────────────── ───────────────────── ────────── ───────────

Restore an environment

Backups can be restored to an environment easily.

Use skpr backup list to find the name of the backup you want to restore.

$ skpr backup restore dev BACKUPNAME
Restoring dev
Restore dev-cwrvh completed in 3m10s

Deep Dive

Backups use Restic under the hood to perform backups.

The Operator which executes the "system" backups can be found here.

We chose this approach over Velero because we only want to backup the state eg. database and files.