English spoken conference

Snapshots

Snapshots

A snapshot is a complete backup of an environment, including all persistent data from running services and files stored in mounted volumes.

Snapshots and Restore

Snapshots can be created with the following command:

1
$ symfony env:snapshot:create

Caution

Triggering a snapshot causes a momentary pause in site availability so that all requests can complete, allowing the snapshot to be taken against a known consistent state. The total interruption is usually only 1-2 seconds and any requests during that time are held temporarily, not dropped.

Use snapshot IDs via symfony env:snapshots to restore them:

1
2
$ symfony env:snapshots
$ symfony env:snapshot:restore 92c9a4b2aa75422efb3d

Tip

It is strongly recommended to make a snapshot of the live environment before merging an environment to the live environment, or when increasing the storage space of a service.

Automated Snapshots

No snapshots are triggered automatically. You can use the env:snapshot:create command to automate snapshots, including from the application container itself via a cron task:

1
2
3
4
5
6
7
8
9
crons:
    snapshot:
        # everyday at 5AM
        spec: 0 5 * * *
        cmd: |
            # only snapshot the master environment, aka production
            if [ "$SYMFONY_BRANCH" = master ]; then
                croncape symfony snapshot:create --no-wait
            fi

For the command to work, set up an authentication token.

Note

Do not schedule more than one snapshot a day to minimize data usage.

Retention

Snapshots are guaranteed to be kept for at least 7 days.

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.