Use backup-manager on Linux for system backup, wiibackupmanager

Source: Internet
Author: User
Tags passwordless ssh

Use backup-manager on Linux for system backup, wiibackupmanager

Whether simple or not, we have the opportunity to understand the importance of backup. Considering that the backup method is really versatile, you may want to know how to effectively select the right tools and appropriate policies for your system.

In this article, I will introduce you to backup-manager, a simple and easy-to-use command line backup tool, which can be seen in most standard software libraries of Linux releases.

What makes the backup manager stand out among many backup tools or backup policies? Let me briefly introduce some of its distinctive features:

  • Simple Design and Management: configuration files are easy to understand and edit, and can be easily used by beginners.
  • Once and for all: it can run cyclically through cron after being configured.
  • Supports multi-protocol remote backup: seamless integration of multiple transport protocols, applications and cloud backend (such as, FTP, SCP, SSH-GPG, rsync, AWS S3, etc) to transmit the generated archive package to a group of remote hosts.
  • Database Backup: supports out-of-the-box backup of MySQL/MariaDB and PostgreSQL databases.
  • Support encryption: GPG-based file encryption is supported during the backup process.
Install the backup manager on Linux

The installation of the backup manager is fast and painless because it is included in the basic software libraries of most Linux distributions.

Debian, Ubuntu and its derivative versions
 
 
  1. # aptitude install backup-manager

During Debian-based installation, you will be prompted to enter the directory for storing the backup and archive files. If the selected directory does not exist, it is automatically created when you run the backup manager for the first time.

Select OK and press Enter.

In the next step, you will be asked about all the directories to be backed up (separated by spaces ). It is recommended, but not strictly, to list the subdirectories in the same parent directory, rather than simply entering the parent directory.

You can skip this step and set the BM_TARBALL_DIRECTORIESb variable in the configuration file later. Otherwise, add as many directories as possible and select OK:

Fedora or CentOS/RHEL
 
 
  1. # yum install backup-manager

On CentOS/RHEL, before running the preceding yum command, you must first start using the EPEL repository.

Configure backup Manager

The master profile for the backup manager is/etc/backup-manager.conf. This file is divided into several chapters, which define the backup method and related variables (or "key value"). These configurations make the backup manager a diverse tool, various situations can be dealt with extensively.

For demonstration purposes, we will consider the following environments:

  • Perform a full backup of the/etc,/home, And/var/log directories every week (we will set the backup frequency through cron below ).
  • Backup the archive file through sshtransmission .tar.gz to the target directory specified on dev1 and dev3 on two different hosts.
  • Back up the local MySQL database to the same target host through SSH.

Open the/etc/backup-manager.conf file with your favorite text editor and edit the following variables. If you want to, you can ignore the rows starting. In this article, it is only used as a description note:

 
 
  1. # Specify the backup method(s) that will be used.
  2. # tarball: takes a list of directories and builds the corresponding tarballs.
  3. # mysql: archives MySQL databases using mysqldump. To restore the database, you # need to use the same tool manually.
  4. export BM_ARCHIVE_METHOD="tarball mysql"
  5.  
  6. # Where to store the backups.
  7. export BM_REPOSITORY_ROOT="/var/archives"
  8.  
  9. # The following directive indicates backup-manager to name
  10. # the generated files after the directory that was backed up.
  11. export BM_TARBALL_NAMEFORMAT="long"
  12.  
  13. # Define the compression type for the generated files.
  14. export BM_TARBALL_FILETYPE="tar.gz"
  15.  
  16. # List the directories that you want to backup.
  17. export BM_TARBALL_DIRECTORIES="/etc /home /var/log"
  18.  
  19. # Exclude some subdirectories or file extensions.
  20. export BM_TARBALL_BLACKLIST="/var/log/myotherapp.log *.mp3 *.mp4"
  21.  
  22. # List the database(s) that you want to backup, separated by spaces.
  23. export BM_MYSQL_DATABASES="mysql mybase wordpress dotclear phpbb2"
  24.  
  25. # MySQL username.
  26. export BM_MYSQL_ADMINLOGIN="root"
  27.  
  28. # MySQL password for username.
  29. export BM_MYSQL_ADMINPASS="mypassword"
  30.  
  31. # Add support for DROP statements (optional).
  32. export BM_MYSQL_SAFEDUMPS="true"
  33.  
  34. # The hostname or IP address where the database(s) reside.
  35. export BM_MYSQL_HOST="localhost"
  36.  
  37. # Port where MySQL server is listening.
  38. export BM_MYSQL_PORT="3306"
  39.  
  40. # Compression type (optional).
  41. export BM_MYSQL_FILETYPE="gzip"
  42.  
  43. # Do not archive remote hosts, but only localhost.
  44. BM_TARBALL_OVER_SSH="false"
  45.  
  46. # User account for SSH upload.
  47. export BM_UPLOAD_SSH_USER="root"
  48.  
  49. # Absolute path of the user's private key for passwordless SSH login.
  50. export BM_UPLOAD_SSH_KEY="/root/.ssh/id_rsa"
  51.  
  52. # Remote hosts (make sure you have exported your public key to them):
  53. export BM_UPLOAD_SSH_HOSTS="dev1 dev3"
  54.  
  55. # Remote destination for uploading backups. If it doesn't exist,
  56. # this directory will be created automatically the first time
  57. # backup-manager runs.
  58. export BM_UPLOAD_SSH_DESTINATION="/var/archives/backups/$HOSTNAME"
Run the backup Manager

To manually run the backup manager, enter the following command. You can also choose to add the '-V' identifier to check the running process step by step.

 
 
  1. # backup-manager

The directories listed in BM_TARBALL_DIRECTORIES will be backed up as tarball to the BM_REPOSITORY_ROOT directory, and then transmitted to the dev1 and dev3 hosts specified by BM_UPLOAD_SSH_DESTINATION through SSH.

As you can see in the preceding figure, the backup manager creates a file named/root/. back-manager_my.cnf while running, and the MySQL password is specified through BM_MYSQL_ADMINPASS. In this way, mysqldump can be verified to the MySQL server without accepting the password in plaintext format on the command line, which poses a security risk.

Run the backup manager through cron

Once you decide which day is the best day for weekly backup (the best time), you can have cron run the backup manager for you.

Open the root crontab file (note that you must log on as root ):

 
 
  1. # crontab -e

If you want to run the backup manager at on Sunday, add the following line.

 
 
  1. 15 05 * * 0 /usr/sbin/backup-manager > /dev/null 2>&1
Summary

In this article, I have demonstrated how simple, powerful, and easy-to-use the backup tool of the backup manager. In your backup policy, you may have several other options to consider. Please refer to the manual page or user manual, which also contains several deployment instances and suggestions.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.