Whether simple or not, we have the opportunity to get to know such a thing, and that is the importance of backup can never be underestimated. Taking into account the backup method is really overwhelming, you may want to know how to effectively and choose the right tools and the right strategy for your system.
In this article, I will introduce you to backup-manager, a simple-to-use command-line backup tool, in most Linux distributions standard software library can be seen in its presence.
What makes the Backup Manager stand out from other backup tool or a backup policy as well? Let me briefly explain some of its distinctive features it:
Simple design and management: Configuration files are easy to read and edit, even for beginners is also very easy to use.
Once and for all: It can be configured after the operation periodically by cron.
Support multiple protocols Remote Backup: seamless integration of multiple transport protocols, applications and cloud backend (eg, FTP, SCP, SSH-GPG, rsync, AWS S3, etc.) to transmit the generated archive package to a remote host.
Support database backup: Includes support out of the box backup MySQL / MariaDB and PostgreSQL databases.
Encryption support: supports GPG backup file encryption.
Install Backup Manager on Linux
Backup Manager Installation is quick and painless, since it is included in most Linux distributions based software repository.
Debian, Ubuntu and its derivatives Edition
# Aptitude install backup-manager
When Debian-based systems installed, you will be prompted to enter the directory where the backup archive. If the selected directory does not exist, then it is automatically created when you first run the Backup Manager.
Select OK and press Enter.
In the next step, we will ask all directories you want to back up (separated by spaces). Proposal, but not strictly required, the same parent directory lists several subdirectories, rather than simply enter the parent directory.
You can skip this step and later on in the configuration file BM_TARBALL_DIRECTORIESb variable settings. Otherwise, please add as many directories you want, and then select OK:
Fedora or CentOS / RHEL
# Yum install backup-manager
On CentOS / RHEL, before running the above command yum, you will need to enable EPEL repository.
Configuration Backup Manager
Backup Manager is the main configuration file /etc/backup-manager.conf. The document is divided into several sections, which define backup methods and variables associated (or "key"), so that these configurations Backup Manager as a diversification tool that can be widely cope with the situation.
For demonstration purposes, we will consider the following environments:
Weekly / etc, / home and / var / log directory to conduct a full backup (which we'll set the backup frequency by cron).
By SSH transport .tar.gz backup archive to two different hosts dev1 and dev3 specified target directory.
Local MySQL database backup to the same destination host via SSH.
Use your favorite text editor to open /etc/backup-manager.conf file and edit the following variables. If you wish, you need not bother those lines starting with #. In this context, it is only used as a comment note:
# Specify the backup method (s) that will be used.
# Tarball: takes a list of directories and builds the corresponding tarballs.
# Mysql: archives MySQL databases using mysqldump To restore the database, you # need to use the same tool manually..
export BM_ARCHIVE_METHOD = "tarball mysql"
# Where to store the backups.
export BM_REPOSITORY_ROOT = "/ var / archives"
# The following directive indicates backup-manager to name
# The generated files after the directory that was backed up.
export BM_TARBALL_NAMEFORMAT = "long"
# Define the compression type for the generated files.
export BM_TARBALL_FILETYPE = "tar.gz"
# List the directories that you want to backup.
export BM_TARBALL_DIRECTORIES = "/ etc / home / var / log"
# Exclude some subdirectories or file extensions.
export BM_TARBALL_BLACKLIST = "/ var / log / myotherapp.log * .mp3 * .mp4"
# List the database (s) that you want to backup, separated by spaces.
export BM_MYSQL_DATABASES = "mysql mybase wordpress dotclear phpbb2"
# MySQL username.
export BM_MYSQL_ADMINLOGIN = "root"
# MySQL password for username.
export BM_MYSQL_ADMINPASS = "mypassword"
# Add support for DROP statements (optional).
export BM_MYSQL_SAFEDUMPS = "true"
# The hostname or IP address where the database (s) reside.
export BM_MYSQL_HOST = "localhost"
# Port where MySQL server is listening.
export BM_MYSQL_PORT = "3306"
# Compression type (optional).
export BM_MYSQL_FILETYPE = "gzip"
# Do not archive remote hosts, but only localhost.
BM_TARBALL_OVER_SSH = "false"
# User account for SSH upload.
export BM_UPLOAD_SSH_USER = "root"
# Absolute path of the user's private key for passwordless SSH login.
export BM_UPLOAD_SSH_KEY = "/ root / .ssh / id_rsa"
# Remote hosts (make sure you have exported your public key to them):
export BM_UPLOAD_SSH_HOSTS = "dev1 dev3"
# Remote destination for uploading backups. If it does not exist,
# This directory will be created automatically the first time
# Backup-manager runs.
export BM_UPLOAD_SSH_DESTINATION = "/ var / archives / backups / $ HOSTNAME"
Run Backup Manager
To manually run the Backup Manager, enter the following command. You can also choose to add the '-v' identification so that step by step detailed inspection during operation.
BM_TARBALL_DIRECTORIES directory listed as the backup tarball to BM_REPOSITORY_ROOT directory, and then transferred to the specified host dev1 BM_UPLOAD_SSH_DESTINATION and dev3 via SSH.
Backup Manager is running when you create a file called /root/.back-manager_my.cnf of, MySQL password BM_MYSQL_ADMINPASS specified. So, mysqldump can authenticate to MySQL server, rather than on the command line to accept the password in plain text format, as a security risk.
Run by cron Backup Manager
Once the decision is to be the best day day (best time) weekly backups, you can get cron to run the Backup Manager for you.
Open root's crontab file (note that you must be logged in root):
# Crontab -e
Suppose you want to run the backup manager on Sunday morning 5:15 minutes, then add the following line.
1505 ** 0 / usr / sbin / backup-manager> / dev / null2> & 1
In this article, I've shown the Backup Manager backup tool is how simple and powerful, and easy to use. In your backup strategy, you may have a few other options to consider, please refer to the manual page or user manual, which also includes several deployment examples and suggestions.
I hope this article help you, please feel free to ask questions and comment below.