I setup a script to automatically backup the database and upload it to my Dropbox account, here's the code:
#!/bin/bash
DATE=$(date +"%Y-%m-%d-%H-%M-%S")
mysqldump -u USER -PASSWORD DB_NAME | gzip -9 > /tmp/$DATE.sql.gz
./root/Dropbox-Uploader/dropbox_uploader.sh upload /tmp/$DATE.sql.gz /
rm /tmp/$DATE.sql.gz
Credits to andreafabrizi and INKHORN.
I put the file inside /etc/cron.hourly
It works just file, the only problem is that it causes MySQL
to not answer any calls from NGINX
during that time (while it creates the backup, depends on size, 20 MB takes about 20 seconds, I see this as serious problem when the database gets larger), which gives the 502 Bad Gateway
error.
Is there any way I can stop this from happening?