Skip to main content

Bacula Restores

Bacula DB Restore


------------------------------------------------------------------------------------------------------------------------------------------ 

Restore Command

------------------------------------------------------------------------------------------------------------------------------------------ 

https://kb.ukfast.net/Restore_MySQL_from_Bacula 

Bconsole > restore > 3 > select Job IDs > Mark /var/lib/mysql > done > 9 (where) > /root/restore_TICKETNUMBER  

Once MySQL has been restored onto client server, we then need to start a 2nd instance of mysql:  

-update the restore path to start the process from  


/usr/sbin/mysqld --socket=/tmp/mysql2.sock --datadir=/mnt/mysql --skip-networking --pid-file=/tmp/mysql2.pid --user=mysql --skip-grant-tables


Open new ssh windows an connect to MySQL instance:  


mysql -S /tmp/mysql2.sock

Check that all databases are included:  


mysql> SHOW DATABASES;

Next the required databases/tables need to be dumped out:  

  • For all data and databases  


mysqldump -S /tmp/mysql2.sock --all-databases --events --triggers --routines > /root/alldatabases_2017_05_05.sql
  • To dump several but not all databases (substitute databasename1,databasename2 etc)  


mysqldump -S /tmp/mysql2.sock --databases databasename1 databasename2 --events --triggers --routines > /root/databases_2017_05_05.sql

 For a specific database only (substitute databasename)  


mysqldump -S /tmp/mysql2.sock databasename --events --triggers --routines > /root/databasename_2017_05_05.sql
  • For a specific table only (substitute databasename and tablename)  


mysqldump -S /tmp/mysql2.sock databasename tablename > /root/databasename-tablename_2017_05_05.sql

If running into issues with mysqldump (errors) try with –f before db name to ignore errors 

Once the dump is complete, terminate the 2nd instance:  


mysqladmin -S /tmp/mysql2.sock shutdown

------------------------------------------------------------------------------------------------------------------------------------------ ------

2nd MySQL instance not starting

If the 2nd instance of mysql won't start on the client server, there's 2 steps I usually follow: 

  1. Delete the restored content on the client server and start the restore again 

  1. If this still doesn't work, you'll need to start the 2nd MySQL instance using innodb_force_recovery 

To do this, add the following line into /etc/my.cnf: 

innodb_force_recovery = 1 

--innodb-force-recovery=1 

 
Innodb_force_recovery has 6 levels, start with 1 and work through to 6, hopefully one of these will start the mysql instance 

 

Ensure you notify the client that the database had to be restored using the force recovery feature and link to the following doc 

https://dev.mysql.com/doc/refman/8.0/en/forcing-innodb-recovery.html 

 

IMPORTANT! Ensure that you remove the innodb_force_recovery entry from /etc/my.cnf once finished 

 

If errors are being shown regarding the existing my.cnf, you can choose to launch the instance with a setting to ignore my.cnf: 

 

--no-defaults  

 

Example: 

/usr/sbin/mysqld --no-defaults --socket=/tmp/mysql2.sock --datadir=/home/restore_4450884/mysql --skip-networking --pid-file=/tmp/mysql2.pid --user=mysql --skip-grant-tables