Wednesday, December 20, 2017

NetBackup 8.1 and MySQL protection (Windows)

Test environment:
- NetBackup version 8.1
- NetBackup for MYSQL version 8.1.0.0
- Windows 2016 x64
- MySQL 5.7.20

Veritas documentation related to MySQL protection can be found here: https://www.veritas.com/content/support/en_US/doc/127649594-127651726-1


First we see on Veritas website the amazing new feature:

"
Open Source is the wave of the future
Future-proof your RDBMS data protection and ride the wave
By 2018, more than 70% of new in-house applications will be developed on an OSDBMS, and 50% of existing commercial RDBMS instances will have been converted or will be in process of being converted. Whether your RDBMS is traditional or Open Source, rely on NetBackup to protect them.
Protect and harness the speed and economics of Open Source RDBMS
Uniquely integrates leading open source RDBMS database workloads with NetBackup
Get new workload support with open APIs for third party integration for NetBackup
Check back soon for MySQL, PostgreSQL, MariaDB, and SQLite for plugin availability
"

Windows testing:

To fully test this I have used a test database which can be found here : https://github.com/datacharmer/test_db

Simply download the zip and import the database using "mysql -uroot -p < employees.sql"



Perform a check on the database to be sure the import was ok "mysql -uroot -p -t < test_employees_md5.sql"



1. About Netbackup for MySQL

NetBackup supports full instance backups of the MySQL database
NetBackup supports full instance restores of MySQL backups


2. Installing NetBackup for MySQL agent

Download NBMySQLagent.zip from Veritas website
Run setup.exe - press 2 next and one finish. Agent will install by default under "C:\Program Files\Veritas\NBMySQLAgent"


3. Configuring NetBackup for MySQL agent

If you are planning to use another user to perform backups then add it.
GRANT SELECT, INSERT, UPDATE, CREATE, DROP, RELOAD, SHUTDOWN, FILE,
INDEX, ALTER, SUPER, LOCK TABLES, CREATE VIEW, SHOW VIEW, TRIGGER,
CREATE ROUTINE, DELETE, EVENT, ALTER ROUTINE ON *.* TO
'THE_USERNAME'@'localhost' IDENTIFIED BY 'THE_PASSWORD'

Edit the environmental path and include NetBackup binary folder. If you used the default path when Netbackup client was installed, then it should be "C:\Program Files\VERITAS\NetBackup\bin"

Edit nbmysql.conf carefully as following:
- DB_PORT : port on which the MySQL listens (default 3306)
- DB_USER : user that will be able to connect to MySQL
- MySQL_LIB_INSTALL_PATH : path to MySQL library
- NETBACKUP_MASTER_SERVER : NetBackup master server FQDN
- NETBACKUP_POLICY_NAME : name of policy name
- NETBACKUP_SCHEDULE_NAME : only Default-Application-Backup is supported so don't waist your time creating new schedules.
- NETBACKUP_CLIENT_NAME : name of NetBackup client
- SNAPSHOT_SIZE : not needed on Windows
- COPY_ID : only used for restores so it can be ignored for the moment
- MYSQL_TARGET_DIRECTORY : only used for restores so it can be ignored for the moment
- NBMYSQL_LOG_LEVEL : Logging level 4 - for testing purpose
- NBMYSQL_LOG_SIZE : 50MB for testing purpose

Veritas documentation contains a mistake as follows:



4. Create a policy in NetBackup:
Attributes : Policy type is Data Store
Schedules : Edit "Default-Application-Backup" retention
Clients : add NetBackup client name
Backup Selection : there is nothing specified in the documentation of what should be added here.

Notes:
Additional schedules are not supported.
Backup selection needs to be EMPTY.

5. Backup MySQL
From cmd trigger : "nbmysql -o backup -S master_server_name -P policy_name -s schedule_name -l mysql_lib_path -p mysql_port -u mysl_user"
Even if we added all these data in nbmysql.conf you still need to enter them as they are mandatory fields.



Notes:
You cannot backup a single database, it's all or nothing.
You cannot exclude a database from backup, it's all or nothing.
You cannot trigger differential or transaction log backup.
Automatic schedule for MySQL backups cannot be done on Windows. (Documentation says otherwise but looks like nobody from Veritas really tested it)

6. Query master server and display all available backups
From cmd trigger : "nbmysql -o query"



Notes :
Query works but BackupTime is wrong !!!!!!!

7. Restore MySQL
From cmd trigger : nbmysql -o restore -S master_server_name -t target_directory -p
db_port -i copy_id -C client_name
Again, even if we did add all this information in nbmysql.conf it's again needed.



Notes : 
You cannot restore a single database, it's all or nothing.
Everytime you want to restore from a different date you need to modify nbmysql.conf and specify the CopyID and destination path (make sure the folder exists and it's empty)
After restore is done you need to shutdown MySQL and overwrite manually the data folder with the restored data, afterwards you can start MySQL.

More fun:
Let's assume that when the backup is triggered there is an update done on several tables/columns.



NetBackup will do a flush/lock on all databases tables and afterwards it will create a shadow using SYSTEM WRITER but since our update ir running it will wait until it finishes.
After the backup finished the shadow copy is still there and will remain there forever and ever causing the shadow storage to get full at some point and creating more issues.



Final note : NetBackup MySQL agent for Windows is simple a waiste of time, mysqldump is way better from all points of view.

No comments:

Post a Comment

NetBackup 8.X - Windows 2016 - KB4048953 - AddLegacyDriverFiles: Unable to back up image of binary Microsoft Link-Layer Discovery Protocol.

Test environment: OS Name: Microsoft Windows Server 2016 Standard OS Version: 10.0.14393 N/A Build 14393 NetBackup 8.X Error from job ...