Copy Log Agents to host
To copy the log agent logs to Host,
-
Issue the host shell command:
docker run --user root --rm -ti -v log-agent-log:/tmp/log-agent-log -v $HOME/LogAgentLogs:/tmp/dest alpine /bin/sh -c "tar cvzf /tmp/dest/log-agent-logs.tar.gz /tmp/log-agent-log/*"
A folder called ‘LogAgentLogs’ appears under the user’s home directory. It contains a logs archive called ‘log-agent-logs.tar.gz’. An extraction tool such as 7zip (www.7-zip.org) can be used to extract the logs within..
Copy MongoDB logs to host
To copy MongoDB logs to the Host,
-
Issue the host shell command:
docker run --user root --rm -ti -v mongo-log:/tmp/mongo-log -v $HOME/MongoDBLogs:/tmp/dest alpine /bin/sh -c "tar cvzf /tmp/dest/mongodb-logs.tar.gz /tmp/mongo-log/*"
A folder name ‘MongoDBLogs’ appears under the user’s home directory. It contains a logs archive called ‘mongodb-logs.tar.gz’. An extraction tool such as 7zip (www.7-zip.org) can be used to extract the logs within.
View MongoDB Logs
To view the MongoDB logs,
-
Issue the host shell command below:
docker exec -it $(docker ps -q -f name=mongo) /bin/sh -c "tail -30 /var/log/mongodb/mongod.log"
-
Change the number of lines as necessary.
Backup MongoDB Database
To backup MongoDB database,
-
Issue the host shell command below:
docker exec -it $(docker ps -q -f name=mongo) /bin/sh -c "exec mongodump -u _BACKUP_USER_ -p _BACKUP_PASS_ -d _DB1_ -–archive" > /some/path/on/your/host/_DB1_.archive
-
Replace _DB1_ in this command with the value you selected. This will generate the (binary) backup file _DB1_.archive on your host which must be backed up elsewhere.
-
Schedule regular backups by wrapping the command(s) above into a script that can be invoked by the Docker host OS scheduler.