Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the backup-manager tool to back up the system in Linux

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "how Linux uses backup-manager tools to back up the system". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Only after there is something wrong with the computer do you understand the importance of backup. In system operation, timely backup is very necessary. Backup-manager is a command line backup tool. The following editor will introduce how Linux uses the backup-manager backup system.

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

Simple design and management: configuration files are easy to read and edit, even for beginners.

Once and for all: once configured, it can operate periodically through cron.

Support for multi-protocol remote backup: seamlessly integrate multiple transport protocols, applications, and cloud backends (such as FTP,SCP,SSH-GPG,rsync,AWS S3, etc.) to transfer the generated archive packets to a group of remote hosts.

Support for database backup: including out-of-the-box backup of MySQL/MariaDB and PostgreSQL databases.

Support encryption: encryption based on GPG files is supported during backup.

Install backup Manager on Linux

The installation of the backup manager is quick and painless because it is included in the base libraries of most Linux distributions.

Debian,Ubuntu and its derivative version

# aptitude install backup-manager

When installing on a Debian-based system, you will be prompted to enter the directory where you want to store the backup archive files. If the selected directory does not exist, it will be created automatically the first time you run backup Manager.

Select OK and press enter.

In the next step, you will be asked about all the directories you want to back up (separated by spaces). It is recommended, but not strictly required, to list several subdirectories in the same parent directory instead of just 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 you want, and then select OK:

Fedora or CentOS/RHEL

# yum install backup-manager

On CentOS/RHEL, you will need to enable the EPEL repository before running the above yum command.

Configure backup Manager

The main configuration file for the backup manager is / etc/backup-manager.conf. The file is divided into chapters that define backup methods and related variables (or "keys"), and these configurations make the backup manager a diverse tool that can cope with a wide range of situations.

For demonstration purposes, we will consider the following environments:

Make a full backup of the / etc,/home and / var/log directories once a week (we will set the frequency of backups below via cron).

Transfer .tar.gz backup archive files via SSH to the target directories specified on two different hosts dev1 and dev3.

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 like, you can ignore the lines that begin with #. In this article, it is just an explanatory comment:

# 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 doesn't 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 run backup Manager manually, enter the following command. You can also choose to add the'- v 'flag to check the running process step by step.

# backup-manager

The directories listed by BM_TARBALL_DIRECTORIES are backed up to the BM_REPOSITORY_ROOT directory as tarball and then transferred via SSH to the hosts dev1 and dev3 specified by BM_UPLOAD_SSH_DESTINATION.

As you can see in the image above, the backup manager creates a file called / root/.back-manager_my.cnf at run time, and the MySQL password is specified by BM_MYSQL_ADMINPASS. That way, mysqldump can authenticate to the MySQL server without having to accept the password in clear text on the command line, which is a security risk.

Run backup Manager through cron

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

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

# crontab-e

Suppose you want to run the backup manager at 5:15 on Sunday, add the following line.

1505**0/usr/sbin/backup-manager "/ dev/null2" & 1

This is the end of the content of "how to use the backup-manager tool to back up the system in Linux". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report