Skip to main content
This script backs up MongoDB database and stores it in /opt/mongoyedek folder. If there are multiple backups, it keeps the newest 2 and deletes the others.
To prevent filling the server’s disk in case old backups are too many or not deleted, either define a separate disk space for the address where you will take backups or also consider moving backups to a place outside the server.
Edit the ‘Ip,Username,Password’ fields specified for the script according to your own Db information.
If you wish, you can ensure the script runs at a specific time or time period. Cron can be used for this.
Add the line below to the opened file.
In example usage, the script will run on the 1st day of each month at 23:59.