Skip to content

Commit 9a0cacd

Browse files
committed
Added 'no-cron' option, cleanup
1 parent da6aa33 commit 9a0cacd

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ RUN chmod +x /start.sh
1313

1414
VOLUME /backup
1515

16-
CMD '/start.sh'
16+
ENTRYPOINT ["/start.sh"]
17+
CMD [""]

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2014 Ilya Stepanov
3+
Copyright (c) 2014-2015 Ilya Stepanov
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,17 @@ Docker image with mongodump running as a cron task
55

66
### Usage
77

8-
Attach a target mongo container to this container and mount a volume to container's `/data` folder. Backups will appear in this volume. Optionally set up cron job schedule (default is `0 12 * * *` - runs every day at 1:00 am).
8+
Attach a target mongo container to this container and mount a volume to container's `/data` folder. Backups will appear in this volume. Optionally set up cron job schedule (default is `0 1 * * *` - runs every day at 1:00 am).
99

1010
docker run -d \
1111
-v /path/to/target/folder:/backup # where to put backups
12-
-e 'CRON_SCHEDULE=0 12 * * *' # cron job schedule
12+
-e 'CRON_SCHEDULE=0 1 * * *' # cron job schedule
1313
--link my-mongo-container:mongo # linked container with running mongo
1414
istepanov/mongodump
15+
16+
To run backup once without cron job, add `no-cron` parameter:
17+
18+
docker run --rm \
19+
-v /path/to/target/folder:/backup # where to put backups
20+
--link my-mongo-container:mongo # linked container with running mongo
21+
istepanov/mongodump no-cron

start.sh

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@
22

33
CRON_SCHEDULE=${CRON_SCHEDULE:-0 1 * * *}
44

5-
echo "$CRON_SCHEDULE /backup.sh" | crontab -
6-
exec cron -f
5+
if [[ "$1" == 'no-cron' ]]; then
6+
exec /backup.sh
7+
else
8+
echo "$CRON_SCHEDULE /backup.sh" | crontab -
9+
exec cron -f
10+
fi

0 commit comments

Comments
 (0)