Exporting a MySQL database: Difference between revisions
>Samthecrazyman m Removed escaping statement, not needed anymore |
m Changed date code in cron command to correct order |
||
| (One intermediate revision by the same user not shown) | |||
| Line 32: | Line 32: | ||
=== Creating the cron job === | === Creating the cron job === | ||
* Log on as <code>root</code> and start KDE Task Scheduler from the Kickstart menu (this can be found by typing 'cron'. | * Log on as <code>root</code> and start KDE Task Scheduler from the Kickstart menu (this can be found by typing 'cron'). | ||
* Select 'System Cron' from the radio buttons in the top task bar. | * Select 'System Cron' from the radio buttons in the top task bar. | ||
* Select 'New entry'. | * Select 'New entry'. | ||
* In the command box, we need to formulate a command. The following command gives most of the things you may need in the command and can be adapted to suit your needs:<br><pre>mysqldump -A -u USER -pPASSWORD > /path/to/backup/backup-name-$(date +% | * In the command box, we need to formulate a command. The following command gives most of the things you may need in the command and can be adapted to suit your needs:<br><pre>mysqldump -A -u USER -pPASSWORD > /path/to/backup/backup-name-$(date +%d-%m-%Y).sql</pre> | ||
** <code>-A</code> switch makes <code>mysqldump</code> backup all databases. | ** <code>-A</code> switch makes <code>mysqldump</code> backup all databases. | ||
** <code>USER</code> should be changed to the user. | ** <code>USER</code> should be changed to the user. | ||
** <code>PASSWORD</code> should be changed to the password used for the user. Notice, no space between the switch <code>-p</code> and <code>PASSWORD</code> or the job will fail. | ** <code>PASSWORD</code> should be changed to the password used for the user. Notice, no space between the switch <code>-p</code> and <code>PASSWORD</code> or the job will fail. | ||
** <code>/path/to/backup</code> should be the full path to the location you want the backup to take place. | ** <code>/path/to/backup</code> should be the full path to the location you want the backup to take place. | ||
** <code>backup-name</code> should be the name of the backup file, <code>$(date +% | ** <code>backup-name</code> should be the name of the backup file, <code>$(date +%d-%m-%Y)</code> adds the date to the place you place it in the file name, especially handy if you want to keep your backups every day. Starting with the year as opposed to the day makes sorting the files in lists a lot easier. | ||
* Select the user you want this to run under (probably root) | * Select the user you want this to run under (probably root) | ||
* Now choose the time and date you would like the backup to take place. If you would like it to happen every day, select the 'Run every day' tick box and this will select all the relevant options, leaving you just to choose a time. | * Now choose the time and date you would like the backup to take place. If you would like it to happen every day, select the 'Run every day' tick box and this will select all the relevant options, leaving you just to choose a time. | ||