None

MongoDB automated snapshot

home automation

WARNING: only use this if your database is small relative to your total storage – the mongodump create full snapshot every time it’s scheduled. See my previous post for MongoDB setup log.

  1. Add folder inside of the jail
    [root@homeauto_database]$ mkdir /mnt/backup
  2. Create folder on the NAS
    [root@freenas]$ mkdir /mnt/mainsafe/archive/shared/mongodb
  3. Link the folders inside of the FreeNAS UI
    cf299f696ce55da18d0e0fe97b22feda.png
  4. Set up backup to BSON files
    [root@homeauto_database]$ vi /root/auto-backup.sh
    #!/bin/sh
    mongodump --db openhab --out /mnt/backup/`date +"%Y%m%d-%H%M"`
    The above scripts creates snapshot of the database openhab (all collections) and timestamps it.
  5. Create a cron entry for the job (in my case every day @2:30am)
    [root@homeauto_database]$ crontab -e
    30 2 * * * /root/auto-backup.sh

 

 

blog comments powered by Disqus