Automatic model of full and differential backup

Source: Internet
Author: User
Title: Automatic model of full and differential backup. 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 following provides a simple script file as an automated model for both full and differential backup. Before using this script, check the environment variables defined in the script header to meet your needs.

#! /Bin/sh

#

#######################################

#

# TAR backup script to cover daily and weekly backups on one tape.

# Generic UNIX version-edit variables as required

#

# For this to work, it MUST be started on a Monday!

#

# Copyright (c) 1999, Tim Jones

# Permission granted for use/modification

#

# Tim Jones/Linux Magazine provide this shell script with no warranty

# (Implied or otherwise)

#

########################################

DOW = 'date + % W'

DATE = 'date + % d'

DAY = 'date + %'

DEVICE = "my rewind tape" # Rewinding tape drive

NDEVICE = "MY NO_REWIND TAPE" # non-rewinding tape drive

REWIND = "mt-f $ DEVICE rewind"

EOD = "mt-f $ NDEVICE eod"

FSF = "mt-f $ NDEVICE fsf"

MAILLIST = "root" # list of users to receive backup notice

If [$ DOW = "6"]

Then

# This is Saturday, so append and write the whole system!

$ EOD

Echo $ DATE>/tmp/. LASTFULL

Tar-cvvf $ NDEVICE/>/tmp/backup.txt

$ REWIND

$ FSF 5

Tar-dvf $ NDEVICE>/tmp/backup.txt

$ REWIND

Cp/tmp/. LASTFULL/etc/. LASTFULL

Else

# This is not Saturday

Case $ DOW in

0)

# It's Sunday-nothing to do

Exit 0

;;

1)

# Monday, Let the tape rewind for the difference verification

Echo $ DATE>/tmp/. LASTINC

Tar-cvvf $ DEVICE -- newer 'cat/etc/. lastfull'/>/tmp/backup.txt

Cp/tmp/. LASTINC/etc/. LASTINC

;;

*)

# Other Days, must rewind manually and Inspect,-I

$ EOD

Echo $ DATE>/tmp/. LASTINC

Tar-cvvf $ NDEVICE -- newer 'cat/etc/. lastinc'/>/tmp/backup

$ REWIND

$ FSF 'expr $ DOW-1'

Echo "************* Verifying $ {DAY}'s backup">/tmp/backup.txt

Tar -- dvf $ NDEVICE>/tmp/backup.txt

Cp/tmp/. LASTINC/etc/. LASTINC

$ REWIND

Esac

Fi

Mail $ MAILLIST </tmp/backup.txt

Rm-f/tmp/backup.txt

# END OF SCRIPT

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.