Skip to content

Instantly share code, notes, and snippets.

@janikvonrotz
Last active July 23, 2023 14:33
Show Gist options
  • Save janikvonrotz/9488132 to your computer and use it in GitHub Desktop.
Save janikvonrotz/9488132 to your computer and use it in GitHub Desktop.
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

@chimit
Copy link

chimit 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
Copy link

oori 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

@dnjora
Copy link

dnjora commented Jul 23, 2023

Just figured out that the link to the file is outdated and has to upload to the server. All in all, it worked.

Next, is to copy the backup to an SFTP server.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment