You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Gaurang Tandon edited this page Jun 6, 2021
·
2 revisions
The backup strategy for the bot data is the same as for any MongoDB database. We use crontab and mongodump. A script runs daily to dump the mongo db contents to a predefined location:
Then, setup another laptop to have ssh access to the above location (using ssh-key password-less identification). Use the following script on this laptop:
#!/bin/bash# CONFIGURAION START
FROM_IP="user@x.y.z.d"
FROM_DIR=""# LCA directory of all the data collections (that need to be backed up)
TO_DIR=""# destination directory for the backups# individual paths of the data collections
FROM_PATHS=( "/path1/dump1""path2/dump2" )
TO_PATHS=( "/dest1""/dest2" )
# CONFIGURAION ENDtimestamp() {
date +"%Y-%m-%d_%H-%M"
}
foriin"${!FROM_PATHS[@]}";do
from=${FROM_PATHS[i]}
to=${TO_PATHS[i]}
FROM_DIR_EXACT="$FROM_DIR$from"
TO_DIR_EXACT="$TO_DIR$to"
FROM_ADDR="$FROM_IP:$FROM_DIR_EXACT"
CURR_DIR="$TO_DIR_EXACT/$(timestamp)"
mkdir -p "$CURR_DIR"
scp -r "$FROM_ADDR""$CURR_DIR"done
Use crontab -e to set up these scripts to run daily. For example, like so: 0 5 * * * /home/user/backup.sh