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 back up a Debian system using backupninja

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly explains "how to use backupninja backup Debian system", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to use backupninja backup Debian system"!

Install Backupninja

Run the following command under your root account:

The code is as follows:

# aptitude install backupninja

During installation, several files and directories will be created:

/ usr/sbin/backupninja is the main script for bash shell

/ etc/cron.d/backupninja, by default, set the cron task to run the above main script every other hour

/ etc/logrotate.d/backupninja truncates logs generated by backupninja programs

/ etc/backup.d/ is the directory where the configuration files of the backup operation reside

/ etc/backupninja.conf is the main configuration file that contains general options. This file is well annotated and explains in detail the meaning of each option

/ usr/share/backupninja is the directory where the scripts used by backupninja are located. These script files are responsible for performing the actual work. In this directory, you can also find .helper files, which can be used to configure and configure ninjahelper menus.

/ usr/share/doc/backupninja/examples contains templates for manipulating configuration files (that is, files generated through ninjahelper).

Run Ninjahelper for the first time

When we try to start ninjahelper, we can see that an internally dependent program may be needed. If prompted, type "yes" and press enter to install dialog (a tool for displaying friendly dialogs from shell scripts).

When you type yes and then hit enter, backupninja will install dialog. Once the installation is complete, it will show the following screenshot:

Case 1: backing up hardware and system information

After starting ninjahelper, we will create a new backup operation:

If the necessary helper programs are not installed, the following screenshot will appear in front of us. If these packages are already installed on your system, please skip this step.

The next step requires you to select the relevant entries as part of this backup task. The first four items have been selected by default, but you can undo the selection by pressing the Spacebar on the item.

Once you have completed the above steps, press the OK option to continue. You will then be able to choose whether you want to use the default configuration file (/ etc/backup.d/10.sys) to complete the backup operation, or to create a new one. In the case of the latter, a file with the same contents as the default profile will be created in the same directory, but it will be named 11.sys, and subsequent backup operations will create similar files (note: only with different serial numbers). It is important to note that once this new configuration file is created, you can use your favorite text editor to edit the file.

Case 2: incremental Rsync pull backup of a remote directory

As you are most likely to know, rsync is widely used to synchronize files or folders over the network. In the next example, we will discuss a method of using hard links to do incremental pull backups for a remote directory, which is used to save historical data and restore it on our local file server. This approach will help us save space and enhance security on the server side.

Step 1: write a custom script with the following content, put it on / etc/backup.d, and set its permissions to 600. It is important to note that in addition to the general configuration files, this directory may also contain some script files that you want to run when backupninja executes, which can take advantage of the variables in the main configuration file.

The code is as follows:

# REMOTE USER

User=root

# REMOTE HOST

Host=dev1

# REMOTE DIRECTORY

Remotedir=/home/gacanepa/

# LOCAL DIRECTORY

Localdir=/home/gacanepa/backup.0

# LOCAL DIRECTORY WHERE PREVIOUS BACKUP WAS STORED

Localdirold=/home/gacanepa/backup.1

Mv $localdir $localdirold

# RSYNC

Rsync-av-delete-recursive-link-dest=$localdirold $user@$host:$remotedir $localdir

In the above configuration, the'--link-dest' option of rsync is used to hard link to the target directory ($localdir) for files that have not changed (including all attributes) located in the $localdir-old directory.

Step 2: before backupninja runs for the first time, the upper directory (in this case, / home/gacanepa) is empty. For the first time, we executed the following command:

The code is as follows:

# backupninja-n

The backup.0 directory is created and its name will be changed to backup.1 in the following process.

When we run backupninja for the second time, the backup.0 will be recreated and the backup.1 will remain unchanged.

Step 3: make sure that the files in the backup.1 are hard-linked to the files in the backup.0. We can do this by comparing the number of inode (I nodes) of the files with the size of the directory.

Summary

Backupninja is not only a classic backup tool, it is also a utility that is easy to configure. You can run backupninja with different configuration files in / etc.backup.d by writing your own control scripts. You can even write helper programs for ninjahelper and include them on the main interface of ninjahelper.

For example, if you create a control script called xmodulo in the / usr/share/backupninja directory, it will automatically run every file in the / etc/backup.d directory with the suffix .xmodulo. If you decide to add your xmodulo control script to ninjahelper, you can write the corresponding helper program, xmodulo.helper. In addition, if you want backupninja to run other scripts, just add it to the / etc/backup.d directory.

Thank you for your reading, the above is the content of "how to use backupninja backup Debian system". After the study of this article, I believe you have a deeper understanding of how to use backupninja backup Debian system, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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