Attix5 Pro FAQ
Search:     Advanced search

Backing Up a MySQL Database using Attix5 Backup Professional SE and scripting

Article ID: 131
Last updated: 30 Jun, 2014

Backing up MySQL requires the user to dump the data to file using the mysqldump utility.

This utility can be run on both Linux and Windows, with minimal installation of additional third-party tools.

Linux

Install Attix5 Backup Professional as normal, then install “script_plugin.jar” into the plugins directory.
You need to create a script file to call the mysqldump utility with the correct parameters.

For example:

  1. Create a text file called “a5mysqldump.pl”
  2. Set the file to be executable with “chmod a+x a5mysqldump.pl”
  3. Open the file using your favourite text editor, and enter the following lines, substituting username, password, and database as appropriate:

    #!/usr/bin/perl
    exec "mysqldump --opt -h hostname -u username --password=password database |gzip > /home/user/testMySQLdump/testdump.gz";

    NOTE: There are only two lines to this script, the second line may be wrapped by your document viewer.
  4. Save the script to a location which the user running the a5backupd service can read. (Usually, this is root, so anywhere will be readable – I used the /home/user/ directory).
  5. Open the a5backup-gui, and select “Tools->Plugins->Scripting”.
  6. Add a new script.


     
  7. Select a name for script, and set the script to run on “Backup start”.
  8. In the “Execute” field, enter the full file path of the script. So, for our example enter “/home/user/a5mysqldump.pl”
  9. In the “Execute in folder” field, enter the filepath of the script file. In our example this is “/home/user/”.
  10. Tick the “Wait for process to complete” checkbox., then click “OK”, then “OK” again to return to the user interface.
  11. In the selection tree, find the dump file directory and include this directory in your selection.
  12. Click on “Backup” to start the backup process. The database should be dumped, then the file backed up.
Windows
  1. Install the script plugin using the plugin installer.
  2. Next create a directory where the dump files will be dumped to, eg C:\MySQLdump\
  3. Next, you need to create a batch file to call mysqldump with the correct parameters.
  4. Open notepad, and enter the following:

    mysqldump --opt -h hostname -u user --password=password database > C:\MySQLdump\testdump.txt

    NOTE: The above text is a single line, which may be wrapped by your document viewer.
  5. Save the batch file into your Attix5 Pro\Backup Client SE\ installation directory as a “.bat” file (in this example, A5MySQLDump.bat was used).
  6. In the Server Edition user interface, go to “Tools->Plugins->Scripting”.
  7. Add a new script.


     
  8. Select a name for script, and set the script to run on “Backup start”.
  9. In the “Execute” field, enter the full file path of the script. So, for our example enter:

    “C:\Program Files\Attix5 Pro\ Backup Client SE\A5MySQLDump.bat”
  10. In the “Execute in folder” field, enter the filepath of the “mysqldump” executable, which is the bin directory for MySQL.
    In our example this is:

    “C:\Program Files\MySQL\MySQL Server 5.0\bin\”
  11. Tick the “Wait for process to complete” checkbox., then click “OK”, then “OK” again to return to the user interface.
  12. In the selection tree, find the dump file directory and include this directory in your selection.
  13. Click on “Backup” to start the backup process. The database should be dumped, then the file backed up.
Article ID: 131
Last updated: 30 Jun, 2014
Revision: 3
Views: 7557
Comments: 0
Posted: 02 Mar, 2012 by Van Rensburg J.
Updated: 30 Jun, 2014 by Van Rensburg J.
This article was:  
Prev   Next
Article 130 - How to restore SQL database files with a .DAT extension     Article 120 - How to backup encrypted files on Windows