Difference between revisions of "Backup MySQL (Ubuntu)"

Jump to navigation Jump to search
m
Added GRANT for backup user
m (typo)
m (Added GRANT for backup user)
Line 6: Line 6:
** Can use [[Acronyms#F|FTPS]] for secure backup transfer
** Can use [[Acronyms#F|FTPS]] for secure backup transfer


To set the script up...
=== Set-up ===
# Create the required folders using...
# Create the required folders using...
#* <code> mkdir backup </code>
#* <code> mkdir backup </code>
Line 19: Line 19:
#* <code> 30 1 * * *      /bin/bash      /backup/mysql.sh </code>
#* <code> 30 1 * * *      /bin/bash      /backup/mysql.sh </code>


To create a MySQL user with limited privileges to run the backup with use...
<source lang="mysql">
GRANT SELECT,LOCK TABLES ON *.* TO backup@'localhost' IDENTIFIED BY 'password';
</source>
=== The Script ===
<source lang="bash">
<source lang="bash">
#!/bin/bash
#!/bin/bash
Line 29: Line 35:


### MySQL Server Login and local backup info ###
### MySQL Server Login and local backup info ###
MUSER="root"                           # MySQL user
MUSER="backup"                         # MySQL user
MPASS="password"                        # MySQL password
MPASS="password"                        # MySQL password
MHOST="localhost"
MHOST="localhost"

Navigation menu