Friday, November 22, 2019

mysqldump backup in MariaDB/mysql


As a DBA taking backup is a common task, and mysqldump utility works with MariadB , i find it a simplest way of taking backups.

Below are few examples of taking backups using mysqldump -

1. Taking full database backup :


mysqldump --all-databases -u root -p > /backup/full-backup.sql


The above will take full backup , backup of all databases


2. Taking backup with triggers,routines,events :


mysqldump --triggers --routines --events --all-databases -u root -p > /backup/full-backup.sql


The above command is useful in taking backups of triggers, routines,events for all the databases.


3. Backup individual databases with triggers,routines,events :


mysqldump --triggers --routines --events --all-databases -u root -p dbname > /backup/full-backup.sql


Replace dbname with your database name in above


4. Export database structure without any data :


mysqldump -u root -p --no-data dbname >  /backup/db-backup.sql


5. Backup a specific table in a database :


mysqldump -u username -p db1 table1 > /backup/db1-table.sql


6. Backup a specific database :


mysqldump - u username -p db1 > /backup/db1-backup.sql


MariaDB

I have been working on a mariadb from sometime now, earlier i have worked on Mysql but lately got an opportunity to work on Mariadb. I have found things similar to MYSQL (i use all the same commands as i have used in MYSQL). Will share new posts related to the same in upcoming days