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

Application of backup and restore function under Linux

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

Share

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

This article mainly explains "the application of backup recovery function under Linux", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let Xiaobian take you to learn "Application of Backup Recovery Function under Linux"!

This article describes how to use backup scripts and commands and commercial software to protect disk data reasonably and efficiently in Linux environments.

Backup and recovery system assumes the function of backup beforehand and recovery afterwards. In the current high-speed development of the network environment, any information system on the network can not guarantee absolute security. As long as there are networks, there will be threats from them. In order to resist the network attack and invasion, although we have introduced the increasingly mature intrusion detection system, firewall system and so on, the hacker's intrusion means are also increasingly sophisticated, they can always find the security loopholes and deficiencies of these systems to invade, so the security incidents caused by network intrusion are increasing year by year.

In this case, it is difficult to guarantee the absolute security of critical systems in the network, so backup and recovery technology is needed. Backup and recovery technology is to use storage media and certain strategies to regularly backup system business data to ensure that data can be recovered as soon as possible when it is accidentally lost, and to minimize the loss of users. It is a very important core technology in information security discipline.

Backup Technology under Linux

For backup and recovery, Linux provides tools such as tar, cpio, dump, etc. to do so. In this way, users do not need to spend money to buy, according to the actual situation of the system, combined with the use of corresponding backup recovery tools to achieve the basic functions of backup and recovery.

tar tool introduction

tar is a classic Unix command ported to Linux. tar is short for tape archive, originally designed to pack files onto tape, but now we mostly use it to back up a partition or some important file directory. We can package the entire directory tree using tar, which makes it particularly suitable for backup. Archive files can be restored in their entirety or expanded into individual files and directories. Backups can be saved to file-based or tape devices. Files can be redirected on restore to relocate them to a different directory (or system) than the directory (or system) where they were originally saved. tar is file system independent, so it has a wide range of applications and can be used on ext2, ext3, jfs, Reiser, and other file systems.

Using tar is very similar to using file utilities such as Winzip and WinRAR in Windows environments. Simply point it to a destination (which can be a file or device) and specify the file you want to package, and you can compress the archive dynamically with standard compression types, or specify an external compressor of your choice. To compress or decompress files via bzip2, use the tar -z command.

Here is a simple example of using the tool for data backup:

tar czvf - /root/code > /tmp/code_bak.tgz (package all program files in/root/code directory to/tmp/code_bak.tgz)

tar xzvf /tmp/code_bak.tgz /root/code (restores a backed up directory file to a specified directory)

Introduction to cpio tools

The cpio command copies files into and out of tar or cpio archives. The cpio command is compatible with tar, but it does have some features that tar does not, as follows:

● Support cpio and tar file formats;

● Support for many legacy tape data formats;

● Ability to read file names through a pipe-line.

At present, it seems that very few Linux packages are distributed in cpio format. If you are interested in the details of the cpio command, you can read its manual with the "man cpio " command.

dump and restore

Dump can perform functions similar to tar. However, dump tends to think about file systems rather than individual files. dump examines files on the ext2 file system and determines which files need to be backed up. These files will be copied to a given disk, tape, or other storage medium for security purposes. On most media, capacity is determined by writing until an end-of-media tag is returned.

The program that works with dump is restore, which restores files from dump images. The restore command performs the reverse function of the dump. A full backup of the file system can be restored first, and subsequent incremental backups can overwrite the restored full backup. Individual files or directory trees can be restored from full or partial backups.

Both dump and restore can be run over the network, so users can backup or restore from remote devices. Dump and restore use tape drives and file devices that offer a wide range of options. However, both are limited to ext2 and ext3 file systems. If you are using JFS, Reiser, or another file system, you will need other utilities, such as tar. For example:

dump 0f /dev/nst0 /(backup ext2 file system to first SCSI device)

restore -xf /dev/nst0 /home/code (restores all data in the/home/code directory of the backed-up SCSI device to disk)

In addition, commercial storage backup tools such as Tivoli Storage Manager exist on the market today, which are visual tools that allow users to easily implement backup and recovery through a user interface. It is worth noting that this is a commercial software, so it is not free, for many users, it provides functions similar to our Linux backup and recovery tools, but more user-friendly and friendly, so that users get rid of the boring command line mode, thus facilitating user use.

Backup needs to spend a certain amount of material and financial resources, how to make a trade-off between the revenue obtained by backup and the resources consumed by backup is a big problem that network security workers need to consider, because spending more than output means inefficiency or even failure. Therefore, data backup in Linux environment needs to be treated differently according to the actual situation to achieve better results. In particular, it is necessary to distinguish some key directories so as to achieve targeted backups and reduce unnecessary waste.

In general, the directories listed below need to be backed up, and they play an important role in the system: /etc contains all core configuration files, including password files, network configuration files, system names, firewall rules, NFS file system configuration files, and other global system entries;/var contains information used by system daemons (services), including DNS configuration, DHCP leases, mail buffer files, HTTP server files, etc.;/home contains the default user home directory for all users, including their personal settings, downloaded files, and important information stored by the user in the system;/root is the home directory of the root user;/bin is an important place to store many commands commonly used in the system, such as ls, ps, etc. These commands have an impact on disk and are extremely vulnerable to hackers.

In contrast, on Linux systems, the following directories should never be backed up: /proc never needs to be backed up, it is not a real file system, but a virtualized view of the running kernel and environment, it includes files such as/proc/cpuinfo,/proc/meminfo, this file is a virtual view of the entire running memory, once the system shutdown or restart, the information in this directory does not exist;/dev A file containing hardware devices indicates that/dev can be backed up if you plan to restore to a blank system, and that backing up/dev is unnecessary if you plan to restore to an installed Linux system; In addition, some soft links (that is, files pointing to other disk files) do not need to be backed up, because these files store only the addresses of the files pointed to. These soft link files can be determined by using the "ls -l" command, as shown below, where linux-2.4 is a soft link file, which points to the linux-2.4.7-10 directory.

At this point, I believe that everyone has a deeper understanding of the "application of backup recovery function under Linux", so it is advisable to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

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