. . .

Configure Backup / Restore Functionality

ApiOmat provides a backup script to automatically dump your data from MongoDB. If you installed MongoDB with default setup the backup script will work after the installation of ApiOmat.

In case you made specific configurations to your MongoDB some changes to the backup script are necessary.
The following articles guides you through the necessary changes:

Add Mongo User Authentication Credentials to Backup Script

If you created a MongoDB user to restrict the access to your database you have to add those credentials to the backup script:

#!/bin/bash
 
# Script which copies daily DB dumps to all application servers in the restoreModule directory.
# Should be called in cron.daily
 
export DATE=`date +"%Y-%-m-%-d"`
export BASE_DUMP_DIR="/srv/restoreModule"
export DUMPDIR=$BASE_DUMP_DIR/$DATE
# DUMPDIR example: /srv/restoreModule/2017-4-27
 
 
mongodump -o $DUMPDIR -u <INSERT_YOUR_MONGO_USER> -p <INSERT_YOUR_MONGO_USERPASSWORD> --authenticationDatabase <INSERT_YOUR_AUTHENTICATION_DB> > /tmp/mongodump.log
 
# cleanup all backups older than 10 days
find $BASE_DUMP_DIR -maxdepth 1 -mtime +10 -type d -exec rm -rf {} \;
@echo off
REM Script which copies DB backups to restoreModule folder
@echo off
for /f "usebackq delims== tokens= 2" %%i in (
`WMIC OS GET localdatetime /format:value`
) do set localTime=%%i
set "YYYY=%localTime:~0,4%"
set "M=%localTime:~4,1%"
set "MM=%localTime:~5,1%"
set "D=%localTime:~6,1%"
set "DD=%localTime:~7,1%"
if %M%==0 set M=
if %D%==0 set D=
set BACKUPDATE=%YYYY%-%M%%MM%-%D%%DD%
set DUMPDIR="C:\mongodb\restoreModule\%BACKUPDATE%"
REM DUMPDIR example: C:\mongodb\restoreModule\2017-4-27
C:\mongodb\bin\mongodump -o %DUMPDIR% -u <INSERT_YOUR_MONGO_USER> -p <INSERT_YOUR_MONGO_USERPASSWORD> --authenticationDatabase <INSERT_YOUR_AUTHENTICATION_DB>

Add customized Host/Port to Backup Script

If you installed MongoDB on a different host/port you have to add the specific host/port credentials to the backup script:

#!/bin/bash
 
# Script which copies daily DB dumps to all application servers in the restoreModule directory.
# Should be called in cron.daily
 
export DATE=`date +"%Y-%-m-%-d"`
export BASE_DUMP_DIR="/srv/restoreModule"
export DUMPDIR=$BASE_DUMP_DIR/$DATE
# DUMPDIR example: /srv/restoreModule/2017-4-27
 
 
mongodump -o $DUMPDIR --host <INSERT_YOUR_HOST_IP> --port <INSERT_YOUR_MONGODB_PORT> > /tmp/mongodump.log
 
# cleanup all backups older than 10 days
find $BASE_DUMP_DIR -maxdepth 1 -mtime +10 -type d -exec rm -rf {} \;
@echo off
REM Script which copies DB backups to restoreModule folder
@echo off
for /f "usebackq delims== tokens= 2" %%i in (
`WMIC OS GET localdatetime /format:value`
) do set localTime=%%i
set "YYYY=%localTime:~0,4%"
set "M=%localTime:~4,1%"
set "MM=%localTime:~5,1%"
set "D=%localTime:~6,1%"
set "DD=%localTime:~7,1%"
if %M%==0 set M=
if %D%==0 set D=
set BACKUPDATE=%YYYY%-%M%%MM%-%D%%DD%
set DUMPDIR="C:\mongodb\restoreModule\%BACKUPDATE%"
REM DUMPDIR example: C:\mongodb\restoreModule\2017-4-27
C:\mongodb\bin\mongodump -o %DUMPDIR% --host <INSERT_YOUR_HOST_IP> --port <INSERT_YOUR_MONGODB_PORT>

Enable Backup / Restore Functionality (Linux)

ApiOmat Yambas contains a Restore Module to backup and restore ApiOmat specific data that is stored within the database. After Installation a restoremodule script will be available within /etc/cron.daily/. This script is not active yet.
To enable the time based backup functionality, simply mark /etc/cron.daily/restoremodule as an executable file via chmod + x /etc/cron.daily/restoremodule .
The command run-parts /etc/cron.daily --test can be used to view all available and runnable daily scripts of your operating system.

Changing the Day Time

To change the day time on which your backup script is running you need to configure your operating system.

On Windows OS you just need to open the task scheduler and reconfigure the basic backup task that was created during installation. On Linux you need to change the file /etc/crontab (https://www.stefanux.de/wiki/doku.php/linux/cronjobs).

* link only available in Enterprise Documentation