Linux Server Backup

Source: Internet
Author: User

Backup Technology under Linux


1. Factors to consider when backing up

Portability (that is, the ability to recover from a backup of the Red Hat Linux system on another system). Whether to back up automatically. The period during which backups are performed. How long the archived backup needs to be kept. User interface friendliness (decide whether you need to select a GUI-based tool or text-based). Whether you need to use compression technology, direct replication, or encryption technology. Backup media (needs to be considered in terms of price, performance, storage capacity). Whether a remote backup or a network backup. Whether to save a file, a subdirectory, or the entire system.

2. Strategy for backup selection

You need to determine the strategy for data backup: Determine what you need to back up, when and how you want to back it up. There are currently 3 backup strategies in the main:

(1) Full backup policy

(2) Incremental backup policy

(3) Differential backup strategy

3, determine the contents of the backup

The Linux file-based nature provides a great deal of convenience for backup and restore systems, which are largely system-neutral, and the Linux backup processes the packaging and unpacking of files.


In general, the following directories need to be backed up:

/etc
Contains all core configuration files. This includes network configuration, system name, firewall rules, users, groups, and other global system entries.

/var
Contains information that is used by the system Daemon (service), including DNS configuration, DHCP tenancy, mail buffer files, HTTP server files, DB2 instance configuration, and so on.

/home
Contains the default user home directory for all users. This includes their personal settings, downloaded files, and other information that the user does not want to lose.

/root
is the root (root) user's home directory.

/opt
is where many non-system files are installed. The IBM software is installed here. OpenOffice, JDK, and other software are also installed here by default.
Some directories should be considered for non-backup.

/proc
You should never back up this directory. It is not a real file system, but a virtualized view that runs the kernel and environment. It includes files such as/proc/kcore, which are virtual views of the entire running memory. Backing up these files is just a waste of resources.

/dev
Contains the file representation of the hardware device. If you plan to restore to a blank system, you can back up/dev. However, if you plan to restore to an installed Linux system, it is not necessary to back up/dev.

3. Backup Tools

For backup and Recovery, Linux provides tools such as tar, cpio, and dump. In this way, users do not have to spend money to purchase, according to the actual situation of the system, with the corresponding backup recovery tool to achieve the basic functions of backup and recovery.

Introduction to Tar Tools

Tar is a classic Unix command that has been ported to Linux. Tar is an abbreviation for Tape archive (tape archive), originally designed to package files on tape, and now most of us use it to back up a partition or some important file directory. We use tar to package the entire directory tree, which makes it particularly suitable for backup. The archive can be restored in its entirety, or a separate file and directory will be expanded from it. Backups can be saved to a file-based device or tape device. Files can be redirected at restore time so that they are re-placed in a different directory (or system) than the directory (or system) in which they were originally saved. Tar is file system-independent, so it can be used on ext2, ext3, JFS, Reiser, and other file systems in a wide range of applications.

Using tar is very similar to using file utilities such as WinZip, WinRAR, and so on in a Windows environment. Simply point it to a purpose (which can be a file or device), then specify the files you want to package, and you can compress the archive dynamically by using a standard compression type, or specify an external compression program of your choice. To compress or decompress a file by bzip2, you can use the Tar-z command.

The following is a simple example of using this tool for data backup:

Tar czvf-/root/code >/tmp/code_bak.tgz (Pack All program files from the/root/code directory to/tmp/code_bak.tgz)

Tar Xzvf/tmp/code_bak.tgz/root/code (restores the backed-up catalog files to the specified directory)

Cpio Tools Introduction

The Cpio command allows you to copy or copy files from a tar or cpio file. The Cpio command is compatible with the tar command, but this command has some functionality that the TAR command does not have, as follows:

Support Cpio and tar two file formats;

Support for many old tape data formats;

The file name of the file can be read through a pipeline (pipe-line).

For now, only a handful of Linux packages are distributed in CPIO format. If you are interested in the details of the Cpio command, you can read its manual using the "man cpio" command.

Dump and restore Introduction

Dump can perform a tar-like function. However, dump tends to consider file systems rather than individual files. Dump checks the files on the ext2 file system and determines which files need to be backed up. These files are copied to a given disk, tape, or other storage media for security protection. On most media, the capacity is determined by writing until a End-of-media tag is returned.

The program that works with dump is restore, which restores files from the dump image. 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 be overwritten on top of the restored full backup. You can restore a separate file or directory tree from a full or partial backup.

Both dump and restore can be run on the network, so users can back up or restore from a remote device. Dump and restore use tape drives and file devices that provide a wide range of options. However, both are limited to ext2 and Ext3 file systems. If you are using JFS, Reiser, or other file systems, you will need other utilities, such as tar. As an example:

Dump 0f/dev/nst0/(back up the ext2 file system to the first SCSI device)

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


Linux Server Backup

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.