Information
Virtual Automation uses MySQL database (on Linux) to store task logs, events, and alerts. In some cases, it is necessary to either migrate the data to another machine, or back up and restore the database on the local machine.
This article provides instructions on how to back up and restore a VA Management Node database.
NOTE: in case of migration the version to a new VA MN, both servers should be installed with exactly the same the version of Virtuozzo Automator.
To migrate/upgrade to Virtuozzo Automator 7, use the instructions from the upgrade guide.
Resolution
Backup (on source node)
-
Stop VA services:
~# systemctl stop va-mn -
Dump tables data only:
~# mysqldump --skip-opt VZAgentDB | grep ^INSERT > inserts.sql -
Get the list of tables and views:
~# echo 'show tables' | mysql VZAgentDB | tail -n +2 > tables.txt -
Dump create statements:
~# for TABLE in `cat tables.txt` ; do echo "SHOW CREATE TABLE $TABLE" | mysql VZAgentDB | tail -n +2 | sed -e 's/^\w\+\s\+//i; s/\\n/ /g; s/$/;/;'; done > creates.sql -
Download attached script for sorting these statements, upload it to the server.
-
Sort create statements:
~# perl sqldump_sort.pl creates.sql > sorted_creates.sql -
for migration only Pack data into archive:
~# tar -cvzf backup_pvamn.tgz sorted_creates.sql inserts.sql -
for migration only Copy data to destination server
Restore (on destination node)
-
Stop MySQL service:
~# systemctl stop mariadb -
Back up all MySQL data:
~# tar -cvzf backup_mysql.tgz /var/lib/mysql -
Start MySQL service:
~# systemctl start mariadb -
for migration only Unpack data from archive:
~# tar -xvzf backup_pvamn.tgz -
Stop PVA services:
~# systemctl stop va-mn -
Drop VZAgentDB database:
~# mysql -NBe "DROP DATABASE VZAgentDB" -
Recreate it:
~# mysql -e 'CREATE DATABASE `VZAgentDB` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin' -
Restore database structure:
~# mysql VZAgentDB < sorted_creates.sql - In case encounter a compatible error on p. 8 run the command and go back to p.6
~# sed -i 's/utf8\tutf8_general_ci//g' sorted_creates.sql -
Restore database contents (it may take a while):
~# (echo "SET FOREIGN_KEY_CHECKS=0;" ; cat inserts.sql ) | mysql VZAgentDB -
Copy the whole
/var/opt/pva/mn/etc/directory from the old PVA Management Node installation to the new server in order to save previous settings. -
Start VA services:
~# systemctl start va-mn