Difference between revisions of "Backup MySQL (Ubuntu)"

Jump to navigation Jump to search
180 bytes removed ,  15:06, 18 January 2021
m
→‎The Script: Updated URL in script
m (Added GRANT for backup user)
m (→‎The Script: Updated URL in script)
 
(3 intermediate revisions by the same user not shown)
Line 14: Line 14:
#* <code> chmod +x /backup/mysql.sh </code>
#* <code> chmod +x /backup/mysql.sh </code>
# Perform a test run of the backup
# Perform a test run of the backup
#* A <code>1044: Access denied for user 'root'@'localhost' to database 'information_schema'</code> error is normal and is due to a longstanding MySQL bug
# Schedule the script to run with crontab
# Schedule the script to run with crontab
#* <code> crontab -e </code>
#* <code> crontab -e </code>
Line 32: Line 31:
# Simon Strutt (Apr 2012)
# Simon Strutt (Apr 2012)
#
#
# See http://www.sandfordit.com/vwiki/index.php/Backup_MySQL_(Ubuntu)
# See https://vwiki.co.uk/Backup_MySQL_(Ubuntu)


### MySQL Server Login and local backup info ###
### MySQL Server Login and local backup info ###
Line 80: Line 79:
     else
     else
         # Is backup required?
         # Is backup required?
         DBUPDATE=`mysql -u root -h localhost -psyndrome -Bse "SELECT max(update_time) FROM information_schema.tables WHERE table_schema='${db}'"`
         DBUPDATE=`mysql -u $MUSER -h $MHOST -p$MPASS -Bse "SELECT max(update_time) FROM information_schema.tables WHERE table_schema='${db}'"`
         DBUPDATEU=`date --date "${DBUPDATE}" +%s`
         DBUPDATEU=`date --date "${DBUPDATE}" +%s`
         #Logger "$db last update was $DBUPDATE"
         #Logger "$db last update was $DBUPDATE"
         if [ -f ${STAMPS}/${db} ]
         if [ -f ${STAMPS}/${db} ]
         then
         then
             BAKDATE=`more ${STAMPS}/${db}`
             BAKDATE=`cat ${STAMPS}/${db}`
             BAKDATEU=`date --date "${BAKDATE}" +%s`
             BAKDATEU=`date --date "${BAKDATE}" +%s`
             #Logger "$db last backup was $BAKDATE"
             #Logger "$db last backup was $BAKDATE"

Navigation menu