Simple and useful mongo database backup container.
3.1K
In this example we are going to backup a database to a volume. When you map the /dump volume this image deletes all dumps of this database older than 30 days.
docker run --rm --name mongodump \
-e DB_HOST=<IP or host> \
-e DB_USER=<username> \
-e DB_PASS=<password> \
-e DB_NAME=<database name to dump> \
-v </path/on/your/host>:/dump \
danitetus/mongodump:latest [mongodump extra args here]
docker run --rm --name mongodump \
-e DB_HOST=<IP or host> \
-e DB_USER=<username> \
-e DB_PASS=<password> \
-e DB_NAME=<database name to dump> \
-e FTP_HOST=<FTP IP or hostname> \
-e FTP_USER=<ftp username> \
-e FTP_PASS=<ftp password> \
-e FTP_DESTINATION=<ftp folder destination> \
danitetus/mongodump:latest [mongodump extra args here]
Tip: You can map the /dump volume to export the backup to FTP and volume
Example of dayly cronjob:
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: backup
spec:
schedule: "0 0 * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: mongodump
image: danitetus/mongodump:latest
args:
- "--authenticationDatabase=admin" ## Optional
- "--authenticationMechanism=SCRAM-SHA-256" ## Optional
- "..." ## All the arguments you need
env:
- name: DB_NAME
value: <database name>
- name: DB_HOST
value: <hostname or IP>
- name: DB_USER
value: <db user>
- name: DB_PASS
value: <db pass>
- name: FTP_HOST
value: <ftp host>
- name: FTP_USER
value: <ftp user>
- name: FTP_PASS
value: <ftp pass>
- name: FTP_DESTINATION
value: <ftp/des/folder>
volumeMounts:
- name: "dump"
mountPath: "/dump"
restartPolicy: OnFailure
volumes:
- name: "dump"
hostPath:
path: "<host destination>
You can customize the behavior of this image with the environment variables:
DB_HOSTThis variable is mandatory and specifies the host of the MongoDB server
DB_NAMEThis variable is mandatory and specifies the name of the database to backup
DB_USERThis variable is mandatory and specifies the user with read access to the database
DB_PASSThis variable is mandatory and specifies the password for that user
FTP_HOSTThis variable is optional and specifies the host of the FTP server. If this variable is not present, tha backup will be backed up only to the volume.
FTP_USERThis variable is optional and specifies the user with write access to the ftp server
FTP_PASSThis variable is optional and specifies the password of the ftp user
FTP_DESTINATIONThis variable is optional and specifies the destination folder in the ftp server to save the backup
View LICENSE file for the software contained in this image.
As with all Docker images, these likely also contain other software which may be under other licenses (such as sh, mongo, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained).
As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Content type
Image
Digest
Size
33.3 MB
Last updated
over 4 years ago
docker pull danitetus/mongodump