Practical Manual: Linux Data Backup

Source: Internet
Author: User

We back up some files to be retained during learning or entertainment. In order to solve the data disaster, we can find and process the files we need in time, so we should back up the data of the files. What we want to talk about today is how to back up data in Linux.

1. manual backup of local data
On Linux, there is a powerful tar command. tar was originally designed for tape backup. Its role is to back up files and directories to tape, then extract or restore files from the tape. Now we can use tar to back up data to any storage media.
The tar command backs up data in the following format:
The command tar cvf backup.tar/home/www is to package/home/www/as a backup.tar file. If we need to compress the file, add the z command.
Using this command, we can manually back up the data on the server, but we also need to use the next technique to achieve regular automatic backup.

2. Automatic Backup of local data
To implement automatic backup, we first need to write the tar command in the script. For example, the following script:
#! /Bin/sh

Tar zcvf test.tar/home/www/
Save as test. sh and add the executable permission. After execution, the following prompt is displayed: tar: Removing leading '/' from member names
This problem occurs because the script is in the user directory by default during execution. In this way, the problem exists. The solution is to switch cd to the directory to be packaged before running tar.

With a script that can execute commands, you need to use scheduled tasks to execute them regularly.

Linux provides cron, a powerful tool that we can use to implement almost any type of timed triggering. Every user has his own cron configuration file. Generally, we run the cron task through the root user to ensure that we can obtain sufficient permissions.
If we want to run the previously written script at every morning, we can use crontab-e to edit the configuration file and add:
0 4 ***/home/test. sh
In this way, the system will automatically run the backup script at every day.

3. Automatic Backup of Dual-Host Data
In terms of security, it is not safe to store backup files on the host machine. In catastrophic circumstances, such backup is very fragile, therefore, we need to back up data to another server. However, we implement dual-host scheduled backup here, instead of real-time backup. Because of the high technical requirements of real-time backup and hot backup, it belongs to commercial applications.

Dual-Machine backup, we can now back up files on the local machine, transfer the backup files to other machines. However, this method is not good and will not be used in practice.
Looking at some information, some say that we can use Mirror to implement dual-host backup [1], but this still requires third-party software. I think it is a good solution, because there is also a powerful tool scp in linux.

At the same time, we can also consider using rsync to synchronize data between two servers. Based on the introduction in this article, we hope you can find a suitable data backup solution.

  1. Knowledge about Suse Chinese Encoding
  2. About Suse FAQ setting ftp service
  3. Suse Linux: shortcuts
  4. Suse kernel transparent proxy
  5. Suse makes the cottage version Chrome

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.