View Progress Of MySQL Dump Restore Or Import
Ever wondered why the MySQL command line tool don’t have any sort of progress bar or information or status update? Well, you’re not alone if you do. Especially importing a GB sized dump file can take a long time, especially if the table engine was InnoDB.
There are some clever utilities which can be used to accomplish just that, by giving the user simple, yet useful information about the progress of their process. Let’s look at how to show progress of mysqldump and other mysql utilities.
Bar (Command Line Progress Bar)
The Bar utility, or in full terms Command Line Progress Bar can be downloaded from Sourceforge. If you are running Ubuntu, it’s as simple as running ‘sudo apt-get install bar’ to install it. You then simply pipe your MySQL import and get a nice status bar.
shell> bar -if=mysql_db_data.sql | mysql
Piper Viewer
To get a bit fancier, Piper Viewer can be inserted into any normal pipeline between two processes to give a visual indication of how quickly data is passing through, how long it has taken, how near to completion it is, and an estimate of how long it will be until completion. Observe multiple instances working in tandem, a visual indicator of relative throughput in a complex pipeline. Download pv here.
shell> pv -cN gzip mysql_db_data.sql.gz | gzip -d | pv -cN mysql | mysql
Either utility will undoubtedly shed more light into your restoration processes, and let you know whether the process is still running if in doubt and wondering after an hour or more. One just has to wonder why MySQL has not already built some feedback into their tools. Maybe one day…