Small server-side app that serves a simple purpose: to receive, manage and monitor various backups.
1.2K
Small server-side app that serves a simple purpose: to receive, manage and monitor various backups.

Create a docker-compose.yaml file:
version: "2"
services:
backupmanager:
image: itglobal/backupmonitor:latest
restart: always
env_file: .env
volumes:
- ./var/app:/var/backupmanager
environment:
- VAR=/var/backupmanager
- LISTEN_ADDR=0.0.0.0:8000
Note that this is an example! You should add an HTTPS proxy for backupmanager container.
Exposing it directly to Internet is not safe.
It's recommended to use https-portal as a reverse proxy or any other product as you see fit.
Create a .env file and configure it (see section below).
At least you'll need to set two variables in .env file:
DOMAIN=your.domain.name.com - domain name for BackupManager instance.JWT_KEY=any-random-string - encryption key for JWT tokens
(try openssl rand -base64 32 to generate one).All other parameters are optional.
Start docker containers:
docker-compose up -d
BackupMonitor is configured via environment variables:
| Variable | Value type | Default value | Description |
|---|---|---|---|
VAR | string | $(pwd)/var | Path to data directory |
LISTEN_ADDR | string | 0.0.0.0:8000 | HTTP endpoint to listen |
JWT_KEY | string | test | Encryption key for JWT tokens |
S3_BUCKET | string | S3 bucket name | |
S3_ACCESS_KEY | string | S3 access key | |
S3_SECRET_KEY | string | S3 secret key | |
S3_DOMAIN | string | https://s3.amazonaws.com | Custom domain for S3 |
SLACK_TOKEN | string | Slack access token | |
SLACK_USERNAME | string | Custom username for Slack notifications | |
TELEGRAM_TOKEN | string | Telegram access token |
File system storage is enabled by default. Backup files will be stored in $VAR/blob/ directory.
In order to enable AWS S3 storage you will need to set following variables:
S3_BUCKET - AWS S3 bucket nameS3_ACCESS_KEY - AWS S3 access keyS3_SECRET_KEY - AWS S3 secret keyS3_DOMAIN - must be empty or non setNote that if credentials aren't valid, BackupManager won't start.
In order to enable custom S3-compatible storage you will need to set following variables:
S3_BUCKET - S3 service bucket name
S3_ACCESS_KEY - S3 service access key
S3_SECRET_KEY - S3 service secret key
S3_DOMAIN - S3 service URL. You may specify:
http://foo.bar.com or https://secure-foo.bar.comfoo.bar.com:8000
(app will assume it's an HTTP endpoint, not an HTTPS one)Note that if credentials aren't valid, BackupManager won't start.
Create a project for backups. Project is basically a container for backup with history and status tracking.
Configure project parameters:
1 day - this means that backups should be taken at least once a day)10 - this means that BackupMonitor will keep 10 last backups)Create an access key for a project.
Write a backup script:
#!/usr/bin/env bash
set -e
# Configure script
BACKUP_FILE="/tmp/my-backip-file"
ENDPOINT="https://my-backup-server.company.com"
ACCESS_KEY="your-access-key"
# TODO Take backup and write it into $BACKUP_FILE
echo "Replace this with actual backup command" > $BACKUP_FILE
# Upload backup
curl -X POST "$ENDPOINT/api/backup" -H "Authorization: $ACCESS_KEY" -F "file=@$BACKUP_FILE"
# Drop local backup file
rm $BACKUP_FILE
Run your script once to make sure it works.
Configure your script to run on a schedule.
There are 3 ways to receive notifications:
BackupManager will detect if project backups are out of date and send notifications every 8 hours.
In order to enable Slack notifications you will need to set following variables:
SLACK_TOKEN - Slack access tokenSLACK_USERNAME - custom username for Slack notifications (this parameter is optional)If a correct access token is set, BackupManager will send notifications to configured Slack channels or users.
Note that you will need to configure notifications for a particular project.
Use @username to send notifications via direct messages and
#channel to send notifications into a channel or a group.
In order to enable Telegram notifications you will need to set following variables:
TELEGRAM_TOKEN - Telegram bot access tokenIf a correct access token is set, BackupManager will send notifications to configured Telegram groups.
Note that you will need to configure notifications for a particular project.
Due to Telegram API limitations you'll have to:
You may specify an URL to receive webhook events from BackupManager if backups are out of date.
BackupManager will make POST requests to specified URL with the following JSON payload:
{
"project" : "PROJECT_ID",
"lastBackupTime" : "2020-01-01T12:00:00Z"
}
There are two options for local development:
using directory as a storage - by default app will store all files in ./var/blob/ directory.
using local Minio as a storage:
Run the following command to set up local minio instance (dockerized):
./scripts/setup-local-env
Create file .env with the following content (it won't be commited into git):
S3_BUCKET=backupmanager
S3_ACCESS_KEY=developer
S3_SECRET_KEY=developer
S3_DOMAIN=http://localhost:9000
Content type
Image
Digest
Size
19.4 MB
Last updated
over 5 years ago
docker pull itglobal/backupmonitor