Companion service to the RethinkDB image for continuous data backup to Tarsnap.

It has two modes of operation. Both modes require the environment variable RETHINKDB_JOIN="[ip of a rethinkdb instance]" and a Tarsnap key with appropriate permissions. The key can be linked as a volume to /tarsnap/tarsnap.key or encoded to base64 and set in the environment variable TARSNAP_KEY_BASE64="[encoded key]".

Backup

Back up a RethinkDB cluster to Tarsnap and delete some of the old archives according to a schedule. Requires a Tarsnap read-write-delete key and the following environment variables:

MODE="backup-and-prune"
BACKUP_INTERVAL="[duration in seconds]" # the interval at which to create backups (optional, defaults to 86400 aka. 24h)
BACKUP_SUFFIX="[word with no spaces]" # a suffix to attach at the end of the archive name (optional)
PRUNE_SCHEDULE="[keep-last or keep-last-month-then-one-per-month]" # choose one of the two schedules (optional, default is no prune)
PRUNE_KEEP_LAST_COUNT="[count]" # number of the latest archives to keep (required if PRUNE_SCHEDULE="keep-last")
PRUNE_MAX_MONTHS="[count]" # number of monthly archives to keep after the complete first month (optional if PRUNE_SCHEDULE="keep-last-month-then-one-per-month", defaults to keeping all)

For example:

MODE="backup-and-prune"
BACKUP_INTERVAL="10800" # back up every 3h
BACKUP_SUFFIX="my-awesome-project"
PRUNE_SCHEDULE="keep-last-month-then-one-per-month"
PRUNE_MAX_MONTHS="24" # keep all backups from last 30 days, plus a backup per month for the next 2 years
RETHINKDB_JOIN="172.17.0.20"
TARSNAP_KEY_BASE64="...BASEXX64XXENCODEDXXKEYXX..."

Restore

Import a Tarsnap archive to a RethinkDB cluster. Requires a Tarsnap read key and the following environment variables:

MODE="restore"
RESTORE_ARCHIVE="[archive]" # name of Tarsnap archive to be imported into RethinkDB