|
Search:
Advanced search
|
Browse by category:
|
KB267: Backing Up a MySQL Database using Attix5 Backup Professional SE and scripting |
|||||
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 For example: Set the file to be executable with “chmod a+x a5mysqldump.pl” 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. 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). Open the a5backup-gui, and select “Tools->Plugins->Scripting”. Add a new script.
Select a name for script, and set the script to run on “Backup start”. In the “Execute” field, enter the full file path of the script. So, for our example enter “/home/user/a5mysqldump.pl” In the “Execute in folder” field, enter the filepath of the script file. In our example this is “/home/user/”. Tick the “Wait for process to complete” checkbox., then click “OK”, then “OK” again to return to the user interface. Find the dump file directory, and select the database dump file or folder for backing up (if a dump file does not yet exist, either run the script separately from command prompt, or start and abort a backup after the script runs). Click on “Backup” to start the backup process. The database should be dumped, then the file backed up. Windows Next create a directory where the dump files will be dumped to, eg C:\MySQLdump\ Next, you need to create a batch file to call mysqldump with the correct parameters. 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. Save the batch file into your Attix 5 Backup Professional installation directory as a “.bat” file (in this example, A5MySQLDump.bat was used). In the Backup Professional user interface, go to “Tools->Plugins->Scripting”. Add a new script.
Select a name for script, and set the script to run on “Backup start”. In the “Execute” field, enter the full file path of the script. So, for our example enter “C:\Program Files\Attix5 Backup Professional SE\A5MySQLDump.bat” 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\”. Tick the “Wait for process to complete” checkbox., then click “OK”, then “OK” again to return to the user interface. Find the dump file directory, and select the database dump file or the folder for backing up (if a dump file does not yet exist, either run the script separately from command prompt, or start and abort a backup after the script runs). Click on “Backup” to start the backup process. The database should be dumped, then the file backed up. |
|||||

