Skip to content

Simple MySQL database backup script

Last updated on March 13, 2019

Create script file

touch /root/mysql-backup/mysqldump.sh

Insert this code

#!/bin/bash
mysqldump -u root -ppassword dbname | bzip2 -c > dbname$(date +%Y-%m-%d-%H.%M.%S).sql.bz2

Make it executable

chmod +x mysqldump.sh

Run it

sh /root/mysql-backup/mysqldump.sh

Done

Published inLinuxScriptShell

Be First to Comment

Leave a Reply