D
D
Dmitry2020-08-29 10:52:33
MySQL
Dmitry, 2020-08-29 10:52:33

How to set up regular mysql database backups on the server?

There is a regular VPS hosting. We want to backup the database to external storage (for example, via FTP) on a schedule (via cron)
How are there options for how to implement this? I'm sure there are already instructions.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Peter, 2020-08-29
@petermzg

#!/bin/bash

filedate=$(date +%Y_%m_%d_%H_%m)
backupname="db_$filedate.sql.gz"
localbkpname="/home/user/backup/$backupname"

mysqldump -uroot -p<pass> <dbname> | gzip -9 > $localbkpname

python dbupload.py $backupname

rm $localbkpname

where pass is the password
dbname is the schema name

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question