Exporting Mysql database with progressbar
mysqldump -command doesn't really support viewing the progress of exporting a database. I guess it's because it gives overhead, and it's frankly quite difficult to generate a fluid progressbar.
Therefore I've created a simple script to show an estimation of the process of a
mysqldump . It does so by calculating the size of all the tables in the given database and comparing this with the size of the resulting sql file.
Simply save the snippet above as
dbexport.sh or something similar. The usage is quite simple:
Although this method isn't precise at all, it gives a good indication of the progress. Handy dandy when exporting bigger databases.
Importing Mysql database with progressbar
Even though the script will output an example one-liner how to re-import the export, the file can easily be imported with the following command:
Don't forget to point to the proper filename and set the proper dbname.
Import / Export with MariaDB
As you may know, some of the original creators of MySQL created MariaDB, since they didn't like the direction Oracle was bringing the project in. Personally I'm a huge fan of open sourced, community-driven and free projects like this. Now, this script will absolutely work with MariaDB — since they're mostly backwards compatible — but might throw you errors in some versions. If so, simply remove the
--defaults-file=/etc/mysql/debian.cnf from the
If you're interested, the
mysqldump commands work without credentials, because of the unix socket authentication plugin, which simply checks if you're root.
$CORRECTIONPERCENTto calculate 10% more size to correct for SQL overhead.
- Changed filename to include time too.
- Simplified filename to
- Used mysqldump options from The best rsync incremental backup script.
gzipcompression, we're assuming a 90% compression ratio here.
- Added separate section for MariaDB.
sudoto ensure access to defaults file.
- Changed options to mysqldump to ensure large databases can be properly exported, also include events and routines.
- Remove the need for
pvshow more details.