There are many commands in the UNIX operating system that can be used to back up files. However, the root file system in the UNIX operating system is a relatively special file. In general, you must uninstall other file systems If you are backing up this type of file. Because the root file system is the ancestor of other filesystems, it backs up files in other file systems at the same time if not uninstalled. But if you uninstall the other file system and then make a backup, then it will be cumbersome. This provides a useful parameter in the Find command to help us achieve this function.
First, the importance of root file system backup and the difficulty of backup.
While the system crashes, it can be recovered by reinstalling the operating system. But this is a lot of work because each external device needs to be reinstalled. In a UNIX operating system, installing and configuring drivers for each external device is a hassle. If a system engineer is able to back up files in the root file system in a normal job, the minimum set of UNIX operating systems is only required when a system failure is encountered, even if the operating system needs to be reinstalled. The configuration files in these root file systems are then restored to the past, eliminating the hassle of configuring external devices.
However, when backing up the root file system, because of its unique status will encounter a lot of trouble. The configuration file in the root file system changes whenever an external device is added to the UNIX operating system, or whenever an external device is unloaded from the system. In other words, the configuration files in the root file system are changing. For this operating system to be able to identify the changed configuration files, and then have the choice to replicate. Otherwise, you will increase the amount of backup effort. Second, because the root file system is the ancestor of other file systems, for this reason, the root file system is backed up, the system will also back up the contents of other file systems. This is certainly not what we want to achieve.
Second, can be the role of the Mount option.
A-mount option is available in the Find command. If you use the Find/-mount command, the operating system does not look for other file system files at the load point. That is, you can use this option to back up only the root file system without having to uninstall other file systems and not access them. Even with this optional find command, the search path is only under the root file system.
For this reason, the common backup strategy for the root file system is that when the system has been fully and correctly configured, the system engineer immediately uses the-mount option to make a full backup of the root file system. Then, each time the configuration files under the root file system change, they are incrementally backed up. Visible through the-mount option, you can resolve the first problem encountered during root file system backup.
Third, to identify whether the document has changed.
To implement incremental backups in a root file backup, the operating system must first determine which files were updated after the last backup. To achieve this, the Find command provides two processing mechanisms, using-newer parameters and-mtime parameters respectively.
1, the use of newer can be implemented by option.
Using the newer option to achieve this requirement is a bit more cumbersome, but comparatively scientific. To use this option to implement this command, it is divided into three main steps.
First step: Create a 0-byte contrast file. The system engineer first uses VI or other tools to create a 0-byte file. What is the purpose of this document, I will talk about it immediately below. This 0-byte file plays a key role in using the newer option to determine which files have been modified since the last backup. What we are using is not the content of the file itself, but the time attribute in this file.
Step two: Use the touch command to modify the time attribute. As we all know, files in Unix operating systems have many attributes, such as creation time, modification time, and so on. In many scripting programs, these file attributes are required. At this point we need to use the modification time attribute in these file attributes. Use the touch command to modify the file's event properties. If we use the touch file name, we can assign the system's current time to the file's modification time section.
Step three: Use the-newer parameter to compare. We use the newer parameter to find the file that changed after the last backup. The main idea is that after the backup is complete, the modified time of the 0-byte file created above is changed to the time after the backup. Then, at the next backup, use the-newer option to compare the modified time of the found file with the modified time of the 0-byte file (the event after the last backup). At this point the Find command only finds those files that are newer than this time and backs them up. This find command plus Touch command, and then combined with the-newer option can be the last backup after the updated file found. So when you write a script, you need to write the find command in front of you. You can use the Touch command to modify the time attribute of a 0-byte file after a backup completes the required files.