This repository contains a Bash script for automating backups of MongoDB databases. The script performs a backup using mongodump
, compresses the backup, and sends it to a specified Telegram chat using the Telegram Bot API.
- Automated backup of MongoDB databases.
- Backup compression using
tar.gz
. - Uploads backup file to Telegram for easy and secure retrieval.
Before using this script, you need to have:
- MongoDB installed and running on your system.
mongodump
utility (usually comes with MongoDB).- A Telegram bot token and chat ID where backups will be sent.
-
Download the script:
wget https://raw.githubusercontent.com/barabum0/mongodump-telegram/main/backup.example.sh -O mongodb_backup.sh
-
Make the Script Executable:
chmod +x mongodb_backup.sh
-
Configure the Script: Edit
mongodb_backup.sh
to set your MongoDB connection details, Telegram Bot Token, and Chat ID.
To manually run the backup script:
./mongodb_backup.sh
To schedule automatic backups using cron:
-
Open your crontab file:
crontab -e
-
Add the following line to run the script every 4 hours:
0 */4 * * * /path/to/your/script/mongodb_backup.sh
Contributions to this script are welcome. Please fork the repository and submit a pull request for any enhancements.
This script is licensed under an MIT license