How to Install, Configure and Run automysqlbackup in Linux

Remembering to always back up a MySQL server can be difficult, but fortunately, there’s a script that can automate the entire process. You won’t even have to write any bash Linux code because skilled programmers already drafted the automysqlbackup script for you. You may even be able to install it automatically.

Getting it to work can be a challenge at times, so we laid out details on the best way to set the software up and then run it. You won’t have to do much once it’s in place.

Method 1: Installing automysqlbackup with a Package Manager

Several Linux distributions like Debian and the various Ubuntu-derived versions including Ubuntu Server allow you to create the automysqlbackup script with nothing but the apt-get package manager. If you’re running a pared-down version of Debian or Ubuntu Server, then you might not have anything but the virtual terminals to work with. In this case, hold down CTRL, ALT and F1 to reach the first terminal and log in.

Users of a light desktop environment distribution still suited for server work like Lubuntu, Xubuntu or Debian-Xfce4 might want to either select the Applications or Whisker menu and click on Root Terminal then type their administration password. You could also hold down Ctrl, Alt and T to open up a standard user prompt.

If you have root access, then type apt-get install automysqlbackup and push enter. You’ll need to type sudo apt-get install automysqlbackup and push enter if you don’t have root access. This should also work on the various derivatives of Linux Mint.

Users of Arch Linux who have root access who’ve followed these steps should be able to install it by running pacman -S automysqlbackup 3.0_rc6-3, though they’ll also need to put sudo in front of the command if they’re running as a root user.

Remembering to always back up a MySQL server can be difficult, but fortunately, there’s a script that can automate the entire process. You won’t even have to write any bash Linux code because skilled programmers already drafted the automysqlbackup script for you. You may even be able to install it automatically.

Getting it to work can be a challenge at times, so we laid out details on the best way to set the software up and then run it. You won’t have to do much once it’s in place.

Method 1: Installing automysqlbackup with a Package Manager

Several Linux distributions like Debian and the various Ubuntu-derived versions including Ubuntu Server allow you to create the automysqlbackup script with nothing but the apt-get package manager. If you’re running a pared-down version of Debian or Ubuntu Server, then you might not have anything but the virtual terminals to work with. In this case, hold down CTRL, ALT and F1 to reach the first terminal and log in.

Users of a light desktop environment distribution still suited for server work like Lubuntu, Xubuntu or Debian-Xfce4 might want to either select the Applications or Whisker menu and click on Root Terminal then type their administration password. You could also hold down Ctrl, Alt and T to open up a standard user prompt.

If you have root access, then type apt-get install automysqlbackup and push enter. You’ll need to type sudo apt-get install automysqlbackup and push enter if you don’t have root access. This should also work on the various derivatives of Linux Mint.

Users of Arch Linux who have root access who’ve followed these steps should be able to install it by running pacman -S automysqlbackup 3.0_rc6-3, though they’ll also need to put sudo in front of the command if they’re running as a root user.

Method 2: Installing automysqlbackup from SourceForge

Users of Fedora, Red Hat, CentOS, Slackware and several other major Linux distributions might find that they don’t have any automysqlbackup package available, so they’ll need to open a browser either by selecting Mozilla Firefox, Chrome, Chromium or Midori from the Applications and then Internet menu in their desktop environment or potentially by holding down the Super key and pushing W. Navigate to https://sourceforge.net/projects/automysqlbackup/ and push enter.

Click on the green Download button and wait for the download to complete. It should only take a few seconds, and SourceForge will automatically offer you a direct link if you’ve been struggling to acquire it. Open up a command prompt then type cd ~/Downloads or instead move to wherever your Downloads directory is. You may, of course, move this file over with a removable device if you need to position it on a server without any GUI or you could theoretically use a command line browser like w3m to download it.

Once you’re in the right directory, type tar zxvf automysqlbackup-v3.0_rc6.tar.gz to extract it. Note that the file name may actually change at some point in the future if there’s any sort of update. You’ll end up with six files, potentially inside of a directory. You may wish to type cd and push tab and then enter to move into said directory. It’s a good idea to run more README before proceeding so you can see what advice the developers give.

Run the install.sh script by typing ./install.sh and pushing the enter key. You’ll need root privileges in order to run it, so you’ll have to preface it with sudo if you’re not at a root shell already. This should take care of everything automatically.

Method 3: Running a Manual Installation

If for some reason the install.sh script fails and you made sure to preface it with the ./ code, then you might have to install it manually. If you don’t already have a root prompt, then create one by typing sudo -i and pushing enter. These commands must be run from the directory you unpacked the tarball into.

It’s a good idea to make a custom configuration file. Use the cp automysqlbackup.conf NAME.conf command, having replaced NAME with an actual name you’d like to give the file.

Method 4: Editing the Configuration File

Open your configuration file with nano or vi and you’ll notice that the file has dozens of comments. You’ll need to enter a MySQL user with at least SELECT privileges, though you probably only have one minimal user on your system. You don’t want to use an administrative account for this. Enter the name inside the single quotes in the line:

CONFIG_mysql_dump_username=”

You’ll need to put their password in between the single quotes in the line:

CONFIG_mysql_dump_password=”

You’ll just need to set the CONFIG_mysql_dump_host variable to CONFIG_mysql_dump_host=’localhost’ since your server is merely the local machine.

Make sure that you set CONFIG_backup_dir= to a directory the user can save backed up files in. For instance, say you have a user called mybackups, then you’ll actually need to use /home/mybackups/backups or else it will attempt to use the user’s directory as a whole. You’ll need to use the mkdir command if said directory doesn’t already exist.

While you can add the names of databases to the CONFIG_db_names=() variable between the parenthesis, leaving it blank will copy all of them. You can use the CONFIG_db_exclude=() parenthesis to add any locations you’d prefer the script to skip over.

The script can hold onto daily backups for a week, but you can change this by changing the CONFIG_rotation_daily= variable to something other than the numeral 7. These defaults might change from time to time. The configuration file we messed with used 6 as the default.

You can then run  from the command line, replacing the name of the file with the one you made, or add it to a startup script or cron. If you needed a cron line, then you might want to try:

0 0 * * *  /usr/local/bin/backupscript

This runs it at midnight each day.

ABOUT THE AUTHOR

Kevin Arrows


Kevin Arrows is a highly experienced and knowledgeable technology specialist with over a decade of industry experience. He holds a Microsoft Certified Technology Specialist (MCTS) certification and has a deep passion for staying up-to-date on the latest tech developments. Kevin has written extensively on a wide range of tech-related topics, showcasing his expertise and knowledge in areas such as software development, cybersecurity, and cloud computing. His contributions to the tech field have been widely recognized and respected by his peers, and he is highly regarded for his ability to explain complex technical concepts in a clear and concise manner.