https://github.com/dr5hn/backup.sh
Backup MySQL & MongoDB | Bash Shell Script | Email Reports
https://github.com/dr5hn/backup.sh
Last synced: 5 months ago
JSON representation
Backup MySQL & MongoDB | Bash Shell Script | Email Reports
- Host: GitHub
- URL: https://github.com/dr5hn/backup.sh
- Owner: dr5hn
- License: mit
- Created: 2020-09-21T08:08:19.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-08T08:13:27.000Z (about 3 years ago)
- Last Synced: 2025-01-08T14:21:50.307Z (5 months ago)
- Language: Shell
- Size: 31.3 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# 🗄️ backup.sh
Backup MySQL & MongoDB | Bash Shell Script | Email Reports
![]()
## Terminology Used
## Prerequisites
- SSH Key Access to Remote Server. [How to setup?](#setup-ssh-key)
- [Sendgrid](https://signup.sendgrid.com/) Account (Optional) -- Incase if you want to turn on reports emailing.# Setup Instructions
### Setting up SSH Key
Make sure to follow the below steps while creating SSH Keys and using them.
Login with username specified in Github Secrets. Generate a RSA Key-Pair:```bash
ssh-keygen -t rsa -b 4096 -C "[email protected]"
```Add newly generated key into Authorized keys.
```bash
cd .ssh && touch authorized_keys && chmod 600 authorized_keys
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
````Copy` the Private Key file content and save it or `download` the Private Key file
```bash
clip < ~/.ssh/id_rsa
```### Test a Connection by supplying downloaded private key
```
ssh -i ~/.ssh/id_rsa user@newserver
```### Update the `PKEY` variable in backup.sh for private key location
```bash
PKEY=id_rsa
to
PKEY=/location_of_your_privatekey
```### Create a conf file using `.example.conf` & Fill up the conf file.
Note: Filename should start with `.` && the positions of variable should stay same refer `backup.sh` file```bash
mv .example.conf .prod_server.conf
```### Update the `SENDGRID_API_KEY` if you want to turn on backup reports emailing. (Optional)
```
SENDGRID_API_KEY=""
to
SENDGRID_API_KEY="your-sendgrid-api-key"
```### Test a Backup Script
```bash
sh backup.sh
```
If all goes well, set it up on cron.### Set it up on Cron
```
0 0 * * * cd /to/location/of/script && sh backup.sh | tee reports.txt # Every Night at Midnight
```
Cron will do remaining..## Contributions / Suggestions / Feedbacks
```
Contributions, Suggestions & Feedbacks are Most Welcome
Get in touch with me at gadadarshan[at]gmail[dot]com
```That's all Folks !! Enjoy.