Backupninja allows you to coordinate system backup by dropping a few simple configuration files into /etc/backup.d/. Most programs you might use for making backups don’t have their own configuration file format. Backupninja provides a centralized way to configure and coordinate many different backup utilities.

Install the backupninja

To install backupninja, you need to log into your server and issue the following commands:

Ubuntu / Debian

apt update -y
apt install backupninja

RHEL & Centos

dnf install epel-release
dnf install backupninja duplicity rdiff-backup

How to backup Linux server backupninja - Image 1

Configuring Backupninja

The backupninja application comes with a handy wizard that will help you set up your backup.

# ninjahelper

How to backup Linux server backupninja - Image 2
MySQL backup

Choose to create a new backup action and MySQL database backup.

How to backup Linux server backupninja - Image 3

Next, you need to enter a directory.

How to backup Linux server backupninja - Image 4
If you need to backup all databases, click YES, otherwise, you have to enter the name of the database to back up.

How to backup Linux server backupninja - Image 5
Set up authentication method, I will choose a password.

How to backup Linux server backupninja - Image 6

Select backup option by spacebar.

How to backup Linux server backupninja - Image 7
Done, the MySQL backup is configured.

How to backup Linux server backupninja - Image 8

Now you can view, edit, disable, rename, run, test, or delete config.

How to backup Linux server backupninja - Image 9
Folder Backup

I ran several websites on the server, so I want to keep website files safe, so I need to create a new backup rule. In my case, I will choose a TAR backup.

How to backup Linux server backupninja - Image 10

Name needed and path for backup.

How to backup Linux server backupninja - Image 11
How to backup Linux server backupninja - Image 12
Choose the compression.

How to backup Linux server backupninja - Image 13

On the next pages, you should enter Includes/Excludes.

How to backup Linux server backupninja - Image 14How to backup Linux server backupninja - Image 15

Done, the backup is configured.

Automate backups 

I will simply add to my cron the next row, so the backup could start every 2 a.m.

0 2 * * * /usr/sbin/backupninja --now

Remove files from backup

Tar backups by default does not have a rotation so you should add the next script to cron to remove files older than 14 days

0 1 * * * find /path/to/backup/* -type f -mtime +14 -exec rm -f {} \;