MongoDB automated snapshot
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.
- Add folder inside of the jail
[root@homeauto_database]$ mkdir /mnt/backup
- Create folder on the NAS
[root@freenas]$ mkdir /mnt/mainsafe/archive/shared/mongodb
- Link the folders inside of the FreeNAS UI
- Set up backup to BSON files
The above scripts creates snapshot of the database openhab (all collections) and timestamps it.[root@homeauto_database]$ vi /root/auto-backup.sh #!/bin/sh mongodump --db openhab --out /mnt/backup/`date +"%Y%m%d-%H%M"`
- 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