Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ubuntu: Install automysqlbackup #MySQL #Markdown

Introduction

AutoMySQLBackup with a basic configuration will create Daily, Weekly and Monthly backups of one or more of your MySQL databases from one or more of your MySQL servers.

Requirements

  • Ubuntu server
  • MySQL

Installation

First create the backup folder.

sudo mkdir /var/backups/mysql

Install the latest version of automysqlbackup from the official website.

sudo mkdir /usr/local/src/automysqlbackup
cd /usr/local/src/automysqlbackup
sudo wget http://switch.dl.sourceforge.net/project/automysqlbackup/AutoMySQLBackup/AutoMySQLBackup%20VER%203.0/automysqlbackup-v3.0_rc6.tar.gz
sudo tar xvzf automysqlbackup-v3.0_rc6.tar.gz
sudo ./install.sh

Answer the install wizard as showed below.

global configuration diectory: default
directory for the executable: default

Add read permissios for all in the config folder.

cd /etc/automysqlbackup
sudo chmod a+r ./*

Update the automysqlbackup config file.

sudo vi /etc/automysqlbackup/automysqlbackup.conf

Set credentials and update the backup path.

# Username to access the MySQL server e.g. dbuser
CONFIG_mysql_dump_username='root'

# Password to access the MySQL server e.g. password
CONFIG_mysql_dump_password='[password]'

# Backup directory location e.g /backups
CONFIG_backup_dir='/var/backups/mysql'

Unlock the latest backup in order to make backups for third party programs available

# Store an additional copy of the latest backup to a standard
# location so it can be downloaded by third party scripts.
CONFIG_mysql_dump_latest='yes'

Let's schedule the backup job by adding a daily cron script.

sudo vi /etc/cron.daily/automysqlbackup

With the following content.

#!/bin/sh

/usr/local/bin/automysqlbackup /etc/automysqlbackup/automysqlbackup.conf

chown root.root /var/backup/mysql* -R
sudo chmod -R a-x+X /var/backup/mysql

Enable execution of the script for the owner.

sudo chmod o+x /etc/cron.daily/automysqlbackup

You can run the backup script manually.

cd /etc/cron.daily
sudo ./automysqlbackup

Checkout the backup folder.

cd /var//backup/mysql

Source

How To Backup MySQL Databases on an Ubuntu VPS by Digital Ocean
How to back up MySQL databases using AutoMySQLBackup by A2 hosting automysqlbackup website

@leomelzer

This comment has been minimized.

Copy link

commented Mar 23, 2016

Thanks for the guide!

I ended up installing the packaged version, available from https://packages.debian.org/jessie/automysqlbackup
It it somewhat more maintained and has some recent bug fixes.

To get rid of all the recommended packages for the installation (they total over 60 MB for me, whereas the script itself is only < 1 MB), run
sudo apt-get --no-install-recommends install automysqlbackup

@chimit

This comment has been minimized.

Copy link

commented Nov 27, 2016

There are two different paths in this article:

/var/backup/mysql

and

/var/backups/mysql

I think, the second one is correct. Other should be fixed.

@oori

This comment has been minimized.

Copy link

commented Sep 23, 2018

The download link isn't current, you can try
sudo wget https://downloads.sourceforge.net/project/automysqlbackup/AutoMySQLBackup/AutoMySQLBackup%20VER%203.0/automysqlbackup-v3.0_rc6.tar.gz

or better, an updated fork here:
sudo wget https://github.com/sixhop/AutoMySQLBackup/archive/3.0.7.tar.gz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.