Automatic Backup on Linux

Source: Internet
Author: User
Article Title: automatic backup on Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

The loss of important data may cause fatal damage. Despite this, countless professionals ignored the backup of their data. Although the causes may vary, the most common explanation is that routine backup is cumbersome. Because the machine is good at completing common and repetitive tasks, the automated backup process is the key to reducing the boring nature of the work and the inherent procrastination.

If you are using Linux, you can use an extremely powerful tool to create custom backup solutions. The solution in this article allows you to use open-source tools to perform simple to more advanced and secure network backup. Almost all Linux releases contain these tools.

Simple backup

This article takes a step-by-step approach. This method is very intuitive as long as you follow these basic steps.

Before learning more advanced distributed backup solutions, let's look at a simple but powerful archiving mechanism. Check a simple script named arc that supports creating backup snapshots from a Linux shell prompt.

Listing 1: arc shell script


#! /Bin/sh
Tar czvf $1. $ (date + % Y % m % d-% H % M % S). tgz $1
Exit $?

The arc script uses a single file or directory name as a parameter to create a compressed archive file and embed the current date into the generated archive file name. For example, if a directory named beoserver exists, you can call the arc script and pass the beoserver directory name to the script to create a compressed archive file, such as beoserver.20040321-014844.tgz.

Use the date command to embed the date and timestamp to help organize archive files. The date format is year, month, day, hour, minute, and second. However, the second field may be redundant. Read the man date manual of the date command to learn about other options of the command. In addition, option-v (verbose) is passed to tar in Listing 1. This option indicates that tar displays all files being archived. If you want to silent the backup process, remove option-v.

Listing 2: archiving beoserver Directories

$ Ls
Arc beoserver
$./Arc beoserver
Beoserver/
Beoserver/bookl. dat
Beoserver/beoserver_ AB _off
Beoserver/beoserver_ AB _on
$ Ls
Arc beoserver beoserver.20040321-014844.tgz

Advanced backup

The preceding simple backup example is useful, but it still contains a manual backup process. We recommend that you back up data frequently and back up data to multiple media in multiple geographic locations. The central idea is to avoid completely relying on a single storage medium and a single storage location.

In the next example, we will solve this challenge and analyze a fictitious Distributed Network (1 ), it shows that a system administrator can access two remote servers and one offline data storage server.

Figure 1. Distributed Network

Backup files of servers #1 and #2 can be securely transmitted to the offline storage server, and the entire distributed backup process will be carried out on a regular basis without human intervention. We will use a set of standard tools, including some Open Secure Shell (OpenSSH) tools, tape archiving tools (tar) and cron task scheduling services. Our entire plan is to use cron for scheduling, use shell programming and tar applications for backup, and use OpenSSH Secure shell encryption for remote access, authentication, and Secure shell replication (scp) to automate file transmission. For more information about these tools, be sure to read their manual.

[1] [2] [3] [4] Next page

Related Article

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.