Starting a temporary MySQL instance for table/DB recovery

In this example we assume a restored backup of mysql’s datadir exists at /mnt/restore/mysql.

mysqld --port=3307 --socket=/mnt/restore/mysql/tmp.sock --datadir=/mnt/restore/mysql --pid-file=/mnt/restore/mysql/tmp.pid --user=mysql

If the backups are ‘dirty’ and innoDB corruption won’t let it start, you can try –innodb-force-recovery=N if needed (start with N = 1 and go up to 4 as neccesary).

If the instance was part of a cluster, you may need to delete galera.cache and dat files.

Once the backup instance is started and running, you can cherry-pick DB’s or tables as needed by using –port=3307 in mysql or mysqldump commands.

If you’re only interested in a single DB, you can save time by skipping unneeded DB’s during the filesystem restore. The following would be a minimal datadir structure for accessing only the “magento” DB:

ibdata1
ib_logfile0
ib_logfile1
magento
mysql

Mysqld will complain about the missing/unwanted DB data folders, but it should still start. It may also start without the ib_logfile0 and ib_logfile1 but could cause issues if the backup is dirty.

Categories: Uncategorized. Bookmark the permalink. Comments Off on Starting a temporary MySQL instance for table/DB recovery

Comments are closed.