Skip to content

Commit

Permalink
Merge pull request #2 from stakater-docker/update-readme
Browse files Browse the repository at this point in the history
[update-readme]
  • Loading branch information
aliartiza75 authored Feb 6, 2020
2 parents 64c8227 + 48be5f3 commit f5c505c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 37 deletions.
50 changes: 18 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,38 +39,24 @@ To use it in k8s configure the variables (in Secrets or manifest) and use the fo

### ENVIRONMENT variables

`AWS_ACCESS_KEY_ID` - your aws access key id (for your s3 bucket)

`AWS_SECRET_ACCESS_KEY`: - your aws secret access key (for your s3 bucket)

`BUCKET`: - your s3 bucket

`BACKUP_FOLDER`: - name of folder or path to put backups (eg `myapp/db_backups/`). defaults to root of bucket.

`MONGODB_HOST` - the host/ip of your mongodb database

`MONGODB_PORT` - the port number of your mongodb database

`MONGODB_USER` - the username of your mongodb database. If MONGODB_USER is empty while MONGODB_PASS is not, the image will use admin as the default username

`MONGODB_PASS` - the password of your mongodb database

`MONGODB_DB` - the database name to dump. If not specified, it will dump all the databases

`EXTRA_OPTS` - any extra options to pass to mongodump command

`CRON_TIME` - the interval of cron job to run mongodump. `0 1 * * *` by default, which is every hour at 0 mins like 1:00, 2:00...

`TZ` - timezone. default: `US/Eastern`

`CRON_TZ` - cron timezone. default: `US/Eastern`

`INIT_BACKUP` - if defined, create a backup when the container launched

`INIT_RESTORE` - if defined, restore from latest when container is launched

`DISABLE_CRON` - if defined, it will skip setting up automated backups. good for when you want to use this container to seed a dev environment.

| Environment Variables | Description |
|---|---|
| AWS_ACCESS_KEY_ID | aws access key id (for your s3 bucket) |
| AWS_SECRET_ACCESS_KEY | aws secret access key (for your s3 bucket) |
| BUCKET | s3 bucket name |
| BACKUP_FOLDER | name of folder or path to put backups (eg `myapp/db_backups/`). defaults to root of bucket. |
| MONGODB_HOST | the host/ip of your mongodb database |
| MONGODB_PORT | the port number of your mongodb database |
| MONGODB_USER | the username of your mongodb database. If MONGODB_USER is empty while MONGODB_PASS is not, the image will use admin as the default username |
| MONGODB_PASS | the password of your mongodb database |
| MONGODB_DB | the database name to dump. If not specified, it will dump all the databases |
| EXTRA_OPTS | any extra options to pass to mongodump command |
| CRON_TIME | the interval of cron job to run mongodump. `0 1 * * *` by default, which is every hour at 0 mins like 1:00, 2:00... |
| TZ | timezone. default: `US/Eastern` |
| CRON_TZ | cron timezone. default: `US/Eastern` |
| INIT_BACKUP | if defined, create a backup when the container launched |
| INIT_RESTORE | if defined, restore from latest when container is launched |
| DISABLE_CRON | if defined, it will skip setting up automated backups. good for when you want to use this container to seed a dev environment. |

## Acknowledgements

Expand Down
4 changes: 2 additions & 2 deletions mongo-restore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mongodb
namespace: pliro-dev
namespace: dev
spec:
serviceName: "mongodb"
selector:
Expand Down Expand Up @@ -92,7 +92,7 @@ metadata:
labels:
app: mongodb
name: mongodb-svc
namespace: pliro-dev
namespace: dev
spec:
ports:
- name: "mongo-port"
Expand Down
6 changes: 3 additions & 3 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,17 @@ ln -s /listbackups.sh /usr/bin/listbackups

touch /mongo_backup.log

if [ -n "${INIT_BACKUP}" ]; then
if [[ "$INIT_BACKUP" == "true" ]]; then
echo "=> Create a backup on the startup"
/backup.sh
fi

if [ -n "${INIT_RESTORE}" ]; then
if [[ "$INIT_RESTORE" == "true" ]]; then
echo "=> Restore store from lastest backup on startup"
/restore.sh
fi

if [ -z "${DISABLE_CRON}" ]; then
if [[ "$DISABLE_CRON" == "true" ]]; then
echo "${CRON_TIME} . /root/project_env.sh; /backup.sh >> /mongo_backup.log 2>&1" > /crontab.conf
crontab /crontab.conf
echo "=> Running cron job"
Expand Down

0 comments on commit f5c505c

Please sign in to comment.