[LinuxFocus-icon]
<--  | äÏÍÏÊ  | ëÁÒÔÁ  | éÎÄÅËÓ  | ðÏÉÓË

îÏ×ÏÓÔÉ | áÒÈÉ×Ù | óÓÙÌËÉ | ðÒÏ LF
[an error occurred while processing this directive]
Brian Hone
Á×ÔÏÒ Brian Hone
<bhone(at)eink.com>

ï Á×ÔÏÒÅ:

Brian Hone ÒÁÂÏÔÁÅÔ ÓÉÓÔÅÍÎÙÍ ÁÄÍÉÎÉÓÔÒÁÔÏÒÏÍ É ÒÁÚÒÁÂÏÔÞÉËÏÍ × ËÏÒÐÏÒÁÃÉÉ E Ink. ÷ Ó×ÏÂÏÄÎÏÅ ×ÒÅÍÑ ÐÌÁ×ÁÅÔ × ÈÏÌÏÄÎÏÊ ×ÏÄÅ É ÚÁÎÉÍÁÅÔÓÑ ÁÌØÐÉÎÉÚÍÏÍ.



ðÅÒÅ×ÏÄ ÎÁ òÕÓÓËÉÊ:
Pukhlyakov Kirill <kirill(at)linuxfocus.org>

óÏÄÅÒÖÁÎÉÅ:

 

Rsync: ÌÕÞÛÁÑ ÓÉÓÔÅÍÁ ÒÅÚÅÒ×ÎÏÇÏ ËÏÐÉÒÏ×ÁÎÉÑ

RSYNC Backup

òÅÚÀÍÅ:

òÅÚÅÒ×ÎÏÅ ËÏÐÉÒÏ×ÁÎÉÅ ÏÄÎÏ ÉÚ ÓÌÏÖÎÙÈ É ÎÁÉÂÏÌÅÅ ÐÒÅÎÅÂÒÅÇÁÅÍÙÈ ÚÁÎÑÔÉÊ ÓÉÓÔÅÍÎÏÇÏ ÁÄÍÉÎÉÓÔÒÉÒÏ×ÁÎÉÑ. îÏ ÎÁ ÓÁÍÏÍ ÄÅÌÅ - ÜÔÏ ÏÞÅÎØ ×ÁÖÎÁÑ ÅÇÏ ÞÁÓÔØ. üÔÏ ÐÏÓÌÅÄÎÑÑ ÎÁÄÅÖÄÁ × ÓÌÕÞÁÅ ÐÒÏÂÌÅÍ Ó ÏÂÏÒÕÄÏ×ÁÎÉÅÍ, ÂÅÚÏÐÁÓÎÏÓÔØÀ É ËÏÎÅÞÎÏ ÖÅ ÚÁÝÉÔÁ ÏÔ ËÏÎÅÞÎÙÈ ÐÏÌØÚÏ×ÁÔÅÌÅÊ. óÕÝÅÓÔ×ÕÅÔ ÍÎÏÇÏ ÓÉÓÔÅÍ ÒÅÚÅÒ×ÎÏÇÏ ËÏÐÉÒÏ×ÁÎÉÑ - ÏÎÉ ÓÔÏÑÔ ÔÙÓÑÞÉ ÄÏÌÌÁÒÏ×, ÉÓÐÏÌØÚÕÀÔ ÄÏÒÏÇÏÅ ÏÂÏÒÕÄÏ×ÁÎÉÅ É ÐÏÓÔÒÏÅÎÙ ÎÁ ÎÅÎÁÄÅÖÎÏÍ ÐÒÏÇÒÁÍÍÎÏÍ ÏÂÅÓÐÅÞÅÎÉÉ. ÷ ÔÏ ÖÅ ×ÒÅÍÑ ÍÙ ÍÏÖÅÍ ×ÙÂÒÁÔØ ÌÕÞÛÅÅ ÒÅÛÅÎÉÅ - Rsync É ÎÅÄÏÒÏÇÏÊ ÄÉÓËÏ×ÙÊ ÍÁÓÓÉ×.

_________________ _________________ _________________

 

ðÒÏÂÌÅÍÁ

èÏÞÕ ÐÅÒÅÞÉÓÌÉÔØ ×ÁÍ ÎÅËÏÔÏÒÙÅ ÐÒÉÞÉÎÙ ÔÏÇÏ, ÞÔÏ ÒÅÚÅÒ×ÎÏÅ ËÏÐÉÒÏ×ÁÎÉÅ ÜÔÏ ÎÁÓÔÏÑÝÉÊ ËÏÛÍÁÒ ÄÌÑ ÓÉÓÔÅÍÎÏÇÏ ÁÄÍÉÎÉÓÔÒÁÔÏÒÁ: ÄÏÒÏÇÏÅ ÏÂÏÒÕÄÏ×ÁÎÉÅ, ËÏÔÏÒÏÅ ÞÁÓÔÏ ÌÏÍÁÅÔÓÑ, ÄÏÒÏÇÏÅ ÐÒÏÇÒÁÍÍÎÏÅ ÏÂÅÓÐÅÞÅÎÉÅ É ËÏÎÅÞÎÏ ÍÁÓÓÁ ×ÒÅÍÅÎÉ, ÐÒÏ×ÅÄÅÎÎÁÑ ÚÁ ×ÏÓÓÔÁÎÏ×ÌÅÎÉÅÍ ÒÁÚÎÙÈ ×ÅÒÓÉÊ ÆÁÊÌÏ×. ôÁËÖÅ ÚÁÍÅÞÕ, ÞÔÏ ÌÉÛØ ÍÁÌÁÑ ÞÁÓÔØ ÉÎÆÏÒÍÁÃÉÉ ËÏÍÐÁÎÉÉ ÓÏÈÒÁÎÑÅÔÓÑ ÉÍÅÎÎÏ ÄÏ ÔÏÇÏ ÍÏÍÅÎÔÁ ËÏÇÄÁ ÏÎÁ ÐÏÎÁÄÏÂÉÔÓÑ. åÓÌÉ ÷Ù ÔÏÔ ÞÅÌÏ×ÅË, ËÏÔÏÒÙÊ ÚÁÎÉÍÁÅÔÓÑ ÓÏÈÒÁÎÅÎÉÅÍ/×ÏÓÓÔÁÎÏ×ÌÅÎÉÅÍ ÄÁÎÎÙÈ, ÎÁ×ÅÒÎÑËÁ ÷ÁÍ ÚÎÁËÏÍ ÓÌÅÄÕÀÝÉÊ ÄÉÁÌÏÇ:

ðÏÌØÚÏ×ÁÔÅÌØ: "ñ ÐÏÔÅÒÑÌ ÆÁÊÌ. ÷Ù ÄÏÌÖÎÙ ÅÇÏ ×ÅÒÎÕÔØ ÍÎÅ.."
óÉÓÔÅÍÎÙÊ ÁÄÍÉÎÉÓÔÒÁÔÏÒ: "èÏÒÏÛÏ, ÎÁÚÏ×ÉÔÅ ÉÍÑ ÆÁÊÌÁ"
ðÏÌØÚÏ×ÁÔÅÌØ: "ñ ÎÅ ÚÎÁÀ, ÍÎÅ ËÁÖÅÔÓÑ, ÞÔÏ × ÎÁÚ×ÁÎÉÉ ÂÙÌÁ ÂÕË×Á 'e'."
óÉÓÔÅÍÎÙÊ ÁÄÍÉÎÉÓÔÒÁÔÏÒ: "èÏÒÏÛÏ, × ËÁËÏÍ ËÁÔÁÌÏÇÅ ÏÎ ÎÁÈÏÄÉÌÓÑ?"
ðÏÌØÚÏ×ÁÔÅÌØ: "ñ ÎÅ ÚÎÁÀ, ÏÎ ÍÏÇ ÂÙÔØ × ÏÄÎÏÍ ÉÚ ÜÔÉÈ ÔÒÅÈ..."
óÉÓÔÅÍÎÙÊ ÁÄÍÉÎÉÓÔÒÁÔÏÒ: "÷Ù ÍÏÖÅÔÅ ÎÁÚ×ÁÔØ ÈÏÔÑ ÂÙ ÄÁÔÕ ËÏÇÄÁ ×Ù ÐÏÓÌÅÄÎÉÊ ÒÁÚ Ó ÎÉÍ ÒÁÂÏÔÁÌÉ?"
ðÏÌØÚÏ×ÁÔÅÌØ: "îÕÕ....íÎÅ ËÁÖÅÔÓÑ ÜÔÏ ÂÙÌÏ × ËÁËÏÊ-ÔÏ ÞÅÔ×ÅÒÇ × ÆÅ×ÒÁÌÅ ÉÌÉ ÁÐÒÅÌÅ. îÅ ÐÏÎÉÍÁÀ × ÞÅÍ ÐÒÏÂÌÅÍÁ? ñ ÄÕÍÁÌ Õ ×ÁÓ ÅÓÔØ ÓÉÓÔÅÍÁ ÒÅÚÅÒ×ÎÏÇÏ ËÏÐÉÒÏ×ÁÎÉÑ, ËÏÔÏÒÁÑ ÐÏÍÏÇÁÅÔ × ÐÏÄÏÂÎÙÈ ÓÉÔÕÁÃÉÑÈ"

 

Rsync

Rsync - ÐÒÅËÒÁÓÎÁÑ ÒÅÁÌÉÚÁÃÉÑ ÎÅÂÏÌØÛÏÇÏ ÁÌÇÏÒÉÔÍÁ. ïÄÎÏ ÉÚ ÇÌÁ×ÎÙÈ ÄÏÓÔÏÉÎÓÔ× ÜÔÏÇÏ ÐÒÉÌÏÖÅÎÉÑ - ÓÐÏÓÏÂÎÏÓÔØ ÜÆÆÅËÔÉ×ÎÏÇÏ ÚÅÒËÁÌÉÒÏ×ÁÎÉÑ ÆÁÊÌÏ×ÏÊ ÓÉÓÔÅÍÙ. ó ÐÏÍÏÝØÀ rsync ÌÅÇËÏ ÐÏÓÔÒÏÉÔØ ÓÉÓÔÅÍÕ ÓÏÈÒÁÎÅÎÉÑ ÆÁÊÌÏ×ÏÊ ÓÉÓÔÅÍÙ, ÉÓÐÏÌØÚÕÀ ÇÉÂËÉÊ ÎÁÂÏÒ ÓÅÔÅ×ÙÈ ÐÒÏÔÏËÏÌÏ×: nfs, smb ÉÌÉ ssh. äÒÕÇÏÅ ÄÏÓÔÏÉÎÓÔ×Ï - ÓÐÏÓÏÂÎÏÓÔØ ÁÒÈÉ×ÉÒÏ×ÁÔØ ÓÔÁÒÙÅ ËÏÐÉÉ ÆÁÊÌÏ×, ËÏÔÏÒÙÅ ÉÚÍÅÎÉÌÉÓØ ÉÌÉ ÂÙÌÉ ÕÄÁÌÅÎÙ. üÔÏ ÄÁÌÅËÏ ÎÅ ×ÓÅ ×ÏÚÍÏÖÎÏÓÔÉ ÉÓÐÏÌØÚÏ×ÁÎÉÑ ÜÔÏÇÏ ÐÒÉÌÏÖÅÎÉÑ, ÒÅËÏÍÅÎÄÕÀ ÷ÁÍ ÐÏÞÉÔÁÔØ ÐÏÄÒÏÂÎÅÅ ÎÁ rsync.samba.org.

 

óÉÓÔÅÍÁ

åÓÌÉ ÂÙÔØ ËÒÁÔËÉÍ × ÏÐÉÓÁÎÉÉ ÓÉÓÔÅÍÙ ÄÏÓÔÁÔÏÞÎÏ ÓËÁÚÁÔØ: ÓÉÓÔÅÍÁ ÓÏÓÔÏÉÔ ÉÚ ÎÅÄÏÒÏÇÏÊ Linux ÍÁÛÉÎÙ ÓÏ ÍÎÏÖÅÓÔ×ÏÍ ÄÅÛÅ×ÙÈ ÄÉÓËÏ× É ÎÅÂÏÌØÛÏÇÏ shell ÓËÒÉÐÔÁ - rsync. [Fig 1] ðÒÏÃÅÓÓ ËÏÐÉÒÏ×ÁÎÉÑ ÓÌÅÄÕÀÝÉÊ: ÓÎÁÞÁÌÁ rsync ÓÏÚÄÁÅÔ ËÁÔÁÌÏÇ 'YY-DD-MM' ÄÌÑ ÓÏÈÒÁÎÅÎÉÑ ÉÚÍÅÎÅÎÎÙÈ ÆÁÊÌÏ×, ÄÁÌÅÅ rsync ÐÒÏ×ÅÒÑÅÔ ÓÅÒ×ÅÒÙ ÕËÁÚÁÎÎÙÅ ÎÁÍÉ ÄÌÑ ÒÅÚÅÒ×ÉÒÏ×ÁÎÉÑ ÎÁ ÎÁÌÉÞÉÅ ÉÚÍÅÎÅÎÉÊ - ÅÓÌÉ ÆÁÊÌ ÂÙÌ ÉÚÍÅÎÅÎ ÓÔÁÒÁÑ ×ÅÒÓÉÑ ËÏÐÉÒÕÅÔÓÑ × ÔÏÌØËÏ ÞÔÏ ÓÏÚÄÁÎÎÙÊ ËÁÔÁÌÏÇ É ÚÁÔÅÍ ÐÅÒÅÐÉÓÙ×ÁÅÔÓÑ ÎÏ×ÏÊ ×ÅÒÓÉÅÊ ÆÁÊÌÁ. [Fig 2]

RSYNC Backup Process

íÏÖÎÏ ÇÏ×ÏÒÉÔØ Ï ÔÏÍ, ÞÔÏ ÅÖÅÄÎÅ×ÎÙÅ ÉÚÍÅÎÅÎÉÑ × ÓÉÓÔÅÍÅ ÓÏÓÔÁ×ÌÑÀÔ ÎÅÂÏÌØÛÕÀ ÞÁÓÔØ ÏÔÎÏÓÉÔÅÌØÎÏ ÆÁÊÌÏ×ÏÊ ÓÉÓÔÅÍÙ - × ÓÒÅÄÎÅÍ ÐÏÒÑÄËÁ .5%...1%. ôÁËÉÍ ÏÂÒÁÚÏÍ, ÉÍÅÑ ÄÌÑ ÒÅÚÅÒ×ÎÏÇÏ ËÏÐÉÒÏ×ÁÎÉÑ ÄÉÓËÉ ÏÂßÅÍÏÍ × Ä×Á ÒÁÚÁ ÐÒÅ×ÙÛÁÀÝÉÅ ÎÁÛÉ ÆÁÊÌÏ×ÙÅ ÓÅÒ×ÅÒÙ, ÍÏÖÎÏ ÈÒÁÎÉÔØ ÂÜËÁÐÙ ÐÒÉÍÅÒÎÏ ÚÁ 50 - 100 ÄÎÅÊ. ëÏÇÄÁ ÍÅÓÔÏ ÎÁ ÄÉÓËÁÈ ÚÁËÏÎÞÉÔÓÑ, ÐÒÏÓÔÏ ÐÏÍÅÎÑÊÔÅ ÉÈ. îÁ ÐÒÁËÔÉËÅ ÐÏÌÕÞÁÅÔÓÑ ÔÁË, ÞÔÏ ÎÁ ÏÄÎÏÍ ÎÁÂÏÒÅ ÄÉÓËÏ× ÍÏÖÎÏ ÈÒÁÎÉÔØ ÉÎÆÏÒÍÁÃÉÀ ÚÁ 6 ÍÅÓÑÃÅ×. îÁ ÓÁÍÏÍ ÄÅÌÅ ÍÏÖÎÏ ÐÅÒÅÄ ÚÁÍÅÎÏÊ ÄÉÓËÏ× ÓËÏÐÉÒÏ×ÁÔØ ÉÈ ÓÏÄÅÒÖÉÍÏÅ ÅÝÅ ËÕÄÁ-ÎÉÂÕÄØ.

How Incremental Files are Handled  

ðÒÅÉÍÕÝÅÓÔ×Á: Á×ÁÒÉÊÎÏÅ ×ÏÓÓÔÁÎÏ×ÌÅÎÉÅ É ×ÏÓÓÔÁÎÏ×ÌÅÎÉÅ ÆÁÊÌÏ× ÔÅÐÅÒØ ÐÒÏÝÅ

÷ÅÒÎÅÍÓÑ Ë ×ÏÏÂÒÁÖÁÅÍÏÍÕ ÄÉÁÌÏÇÕ. ÷ÍÅÓÔÏ ÇÒÏÍÏÚÄËÏÊ ÓÉÓÔÅÍÙ, ÈÒÁÎÑÝÅÊ ÄÁÎÎÙÅ ÎÁ ÌÅÎÔÁÈ, Õ ÎÁÓ ÅÓÔØ ÂÜËÁÐ ÚÁ ÐÏÓÌÅÄÎÉÅ 6 ÍÅÓÑÃÅ× ÎÁ ÎÁÛÅÊ Linux ÍÁÛÉÎÅ. ó ÐÏÍÏÝØÀ ÔÁËÉÈ ÕÔÉÌÉÔ ËÁË locate/find/grep ÌÅÇËÏ ÎÁÊÔÉ ×ÓÅ ËÏÐÉÉ ÆÁÊÌÁ ÏÐÒÅÄÅÌÅÎÎÏÇÏ ÐÏÌØÚÏ×ÁÔÅÌÑ, Ó ÂÕË×ÏÊ 'e' × ÉÍÅÎÉ É ÄÁÔÉÒÕÅÍÙÅ ÞÅÔ×ÅÒÇÏÍ ÆÅ×ÒÁÌÑ ÉÌÉ ÁÐÒÅÌÑ É ÓËÏÐÉÒÏ×ÁÔØ ÉÈ × ÄÏÍÁÛÎÉÊ ËÁÔÁÌÏÇ ÜÔÏÇÏ ÐÏÌØÚÏ×ÁÔÅÌÑ. ðÒÏÂÌÅÍÁ ÐÏÉÓËÁ ËÏÒÒÅËÔÎÏÊ ×ÅÒÓÉÉ ÆÁÊÌÁ - ÍÏÑ ÌÀÂÉÍÁÑ ÐÒÏÂÌÅÍÁ: Ñ ÎÁÚÙ×ÁÀ ÅÅ ÞØÅÊ-ÔÏ ÄÒÕÇÏÊ ÐÒÏÂÌÅÍÏÊ.

äÁÌÅÅ, ÐÒÅÄÓÔÁ×ÉÍ ÓÁÍÙÊ ÐÏÐÕÌÑÒÎÙÊ ÓÃÅÎÁÒÉÊ - complete failure. îÁÐÒÉÍÅÒ ÔÁËÁÑ ÐÒÏÂÌÅÍÁ ÓÌÕÞÉÌÁÓØ Ó ÂÏÌØÛÉÍ nfs/samba ÓÅÒ×ÅÒÏÍ. åÓÌÉ ÷Ù ÄÅÌÁÌÉ ÒÅÚÅÒ×ÎÏÅ ËÏÐÉÒÏ×ÁÎÉÅ ÎÁÓÔÒÏÅË samba ÓÅÒ×ÅÒÁ, ÔÏ ÐÏÄÎÑÔØ ÷ÁÛ ÒÅÚÅÒ×ÎÙÊ ËÏÍÐØÀÔÅÒ × ËÁÞÅÓÔ×Å ÚÁÍÅÎÙ Ó ÐÒÁ×ÁÍÉ ÔÏÌØËÏ ÎÁ ÞÔÅÎÉÅ - ÄÅÌÏ ÎÅÓËÏÌØËÉÈ ÍÉÎÕÔ. ðÒÅÄÓÔÁ×ØÔÅ ÐÏÄÏÂÎÕÀ ÓÉÔÕÁÃÉÀ × ÓÌÕÞÁÅ ÉÓÐÏÌØÚÏ×ÁÎÉÑ ÌÅÎÔ.

 

óÒÁ×ÎÅÎÉÅ ÓÉÓÔÅÍ ÎÁ ÏÓÎÏ×Å Rsync/ÖÅÓÔËÉÅ_ÄÉÓËÉ É ÌÅÎÔ

  ìÅÎÔÙ Rsync
ãÅÎÁ ïÞÅÎØ ×ÙÓÏËÁÑ îÉÚËÁÑ
ðÏÌÎÏÅ ÒÅÚÅÒ×ÎÏÅ ËÏÐÉÒÏ×ÁÎÉÅ âÙÓÔÒÏ âÙÓÔÒÏ
îÁËÁÐÌÉ×ÁÀÝÅÅÓÑ ÒÅÚÅÚÒ×ÎÏÅ ËÏÐÉÒÏ×ÁÎÉÅ âÙÓÔÒÏ âÙÓÔÒÏ
ðÏÌÎÏÅ ×ÏÓÓÔÁÎÏ×ÌÅÎÉÅ ïÞÅÎØ ÍÅÄÌÅÎÎÏ, ×ÏÚÍÏÖÎÏ ÎÅÓËÏÌØËÏ ÌÅÎÔ âÙÓÔÒÏ - ×ÓÅ ÄÁÎÎÙÅ ÎÁ ÏÄÎÏÍ ÄÉÓËÅ
÷ÏÓÓÔÁÎÏ×ÌÅÎÉÅ ÆÁÊÌÏ× íÅÄÌÅÎÎÏ, ×ÏÚÍÏÖÎÏ ÎÅÓËÏÌØËÏ ÌÅÎÔ, ÔÒÕÄÎÏ ÎÁÊÔÉ ÎÕÖÎÕÀ ×ÅÒÓÉÀ. ïÞÅÎØ ÂÙÓÔÒÏ - ×ÓÅ ÄÁÎÎÙÅ ÎÁ ÏÄÎÏÍ ÄÉÓËÅ ÐÌÀÓ ÕÕÔÉÌÉÔÙ UN*X: find, grep É locate
ðÏÌÎÙÊ ÏÔËÁÚ ÓÉÓÔÅÍÙ åÄÉÎÓÔ×ÅÎÎÙÊ ×ÙÈÏÄ - ÐÏÌÎÏÅ ×ÏÓÓÔÁÎÏ×ÌÅÎÉÅ åÓÔØ ×ÏÚÍÏÖÎÏÓÔØ ÂÙÓÔÒÏÇÏ ÐÒÅ×ÒÁÝÅÎÉÑ ÒÅÚÅÒ×ÎÏÇÏ ÓÅÒ×ÅÒÁ × ÆÁÊÌÓÅÒ×ÅÒ.
 

éÎÓÔÒÕÍÅÎÔÙ

ðÏÄÏÂÎÕÀ ÓÉÓÔÅÍÕ ÏÞÅÎØ ÌÅÇËÏ ÐÏÓÔÒÏÉÔØ. ÷ÓÅ ÉÓÐÏÌØÚÕÅÍÙÅ ÉÎÓÔÒÕÍÅÎÔÙ - open-source, ÏÎÉ ÐÏÓÔÁ×ÌÑÀÔÓÑ × ÓÔÁÎÄÁÒÔÎÙÈ ÄÉÓÔÒÉÂÕÔÉ×ÁÈ. ðÒÉ×ÅÄÅÍ ÏÄÉÎ ÐÒÉÍÅÒ ÓÏÚÄÁÎÉÑ ÐÏÄÏÂÎÏÊ ÓÉÓÔÅÍÙ, ÎÏ ÎÅ ÚÁÂÙ×ÁÊÔÅ, ÞÔÏ ÏÎ ÎÅ ÅÄÉÎÓÔ×ÅÎÎÙÊ.

 

ï ÓËÒÉÐÔÅ

óËÒÉÐÔ ÄÏÓÔÕÐÅÎ ÎÁ ÓÁÊÔÅ rsync. éÓÐÏÌØÚÕÊÔÅ ÓÌÅÄÕÀÝÕÀ ËÏÍÁÎÄÕ:

rsync --force --ignore-errors --delete --delete-excluded --exclude-from=exclude_file --backup --backup-dir=`date +%Y-%m-%d` -av

òÁÓÓÍÏÔÒÉÍ ÏÓÎÏ×ÎÙÅ ÏÐÃÉÉ:

üÔÏÔ ÓËÒÉÐÔ ÍÏÖÎÏ ÚÁÐÕÓËÁÔØ ËÁÖÄÕÀ ÎÏÞØ cron'ÏÍ. þÔÏÂÙ ÏÎ ÚÁÐÕÓËÁÌÓÑ ËÁÖÄÙÊ ÄÅÎØ × 11pm ÉÓÐÏÌØÚÕÊÔÅ ÓÌÅÄÕÀÝÕÀ ËÏÍÁÎÄÕ "crontab -e" É ÐÏÔÏÍ ÎÁÂÅÒÉÔÅ:

0 23 * * * /path/to/your/script

 

óÁÍ ÓËÒÉÐÔ

ðÒÉ×ÅÄÕ ÚÄÅÓØ ÍÏÊ ÓËÒÉÐÔ, ÞÔÏÂÙ ÓÏÂÒÁÔØ ×ÓÅ ÓËÁÚÁÎÎÏÅ ×ÙÛÅ ×ÍÅÓÔÅ. åÝÅ ÒÁÚ ÎÁÐÏÍÎÀ, ÞÔÏ ÓÕÝÅÓÔ×ÕÅÔ ÍÎÏÇÏ ÓÐÏÓÏÂÏ× ÒÅÁÌÉÚÁÃÉÉ ÜÔÏÊ ÓÉÓÔÅÍÙ, ÜÔÏ ÐÒÏÓÔÏ ÏÄÉÎ ÉÚ ×ÁÒÉÁÎÔÏ×.

#!/bin/sh

#########################################################
# Script to do incremental rsync backups
# Adapted from script found on the rsync.samba.org
# Brian Hone 3/24/2002
# This script is freely distributed under the GPL
#########################################################

##################################
# Configure These Options
##################################

###################################
# mail address for status updates
#  - This is used to email you a status report
###################################
MAILADDR=your_mail_address_here

###################################
# HOSTNAME
#  - This is also used for reporting
###################################
HOSTNAME=your_hostname_here

###################################
# directory to backup
# - This is the path to the directory you want to archive
###################################
BACKUPDIR=directory_you_want_to_backup

###################################
# excludes file - contains one wildcard pattern per line of files to exclude
#  - This is a rsync exclude file.  See the rsync man page and/or the
#    example_exclude_file
###################################
EXCLUDES=example_exclude_file

###################################
# root directory to for backup stuff
###################################
ARCHIVEROOT=directory_to_backup_to

#########################################
# From here on out, you probably don't  #
#   want to change anything unless you  #
#   know what you're doing.             #
#########################################

# directory which holds our current datastore
CURRENT=main

# directory which we save incremental changes to
INCREMENTDIR=`date +%Y-%m-%d`

# options to pass to rsync
OPTIONS="--force --ignore-errors --delete --delete-excluded \
 --exclude-from=$EXCLUDES --backup --backup-dir=$ARCHIVEROOT/$INCREMENTDIR -av"

export PATH=$PATH:/bin:/usr/bin:/usr/local/bin

# make sure our backup tree exists
install -d $ARCHIVEROOT/$CURRENT

# our actual rsyncing function
do_rsync()
{
   rsync $OPTIONS $BACKUPDIR $ARCHIVEROOT/$CURRENT
}

# our post rsync accounting function
do_accounting()
{
   echo "Backup Accounting for Day $INCREMENTDIR on $HOSTNAME:">/tmp/rsync_script_tmpfile
   echo >> /tmp/rsync_script_tmpfile
   echo "################################################">>/tmp/rsync_script_tmpfile
   du -s $ARCHIVEROOT/* >> /tmp/rsync_script_tmpfile
   echo "Mail $MAILADDR -s $HOSTNAME Backup Report < /tmp/rsync_script_tmpfile"
   Mail $MAILADDR -s $HOSTNAME Backup Report < /tmp/rsync_script_tmpfile
   echo "rm /tmp/rsync_script_tmpfile"
   rm /tmp/rsync_script_tmpfile
}

# some error handling and/or run our backup and accounting
if [ -f $EXCLUDES ]; then
	if [ -d $BACKUPDIR ]; then
		# now the actual transfer
		do_rsync && do_accounting
	else
		echo "cant find $BACKUPDIR"; exit
	fi
	else
		echo "cant find $EXCLUDES"; exit
fi
 

òÅÓÕÒÓÙ

 

óÔÒÁÎÉÃÁ ÏÔÚÙ×Ï×

õ ËÁÖÄÏÊ ÚÁÍÅÔËÉ ÅÓÔØ ÓÔÒÁÎÉÃÁ ÏÔÚÙ×Ï×. îÁ ÜÔÏÊ ÓÔÒÁÎÉÃÅ ×Ù ÍÏÖÅÔÅ ÏÓÔÁ×ÉÔØ Ó×ÏÊ ËÏÍÍÅÎÔÁÒÉÊ ÉÌÉ ÐÒÏÓÍÏÔÒÅÔØ ËÏÍÍÅÎÔÁÒÉÉ ÄÒÕÇÉÈ ÞÉÔÁÔÅÌÅÊ
 talkback page 

<--, ÐÅÒÅÊÔÉ Ë ÎÁÞÁÌØÎÏÊ ÓÔÒÁÎÉÃÅ ×ÙÐÕÓËÁ

Webpages maintained by the LinuxFocus Editor team
© Brian Hone, FDL
LinuxFocus.org
Translation information:
en --> -- : Brian Hone <bhone(at)eink.com>
en --> ru: Pukhlyakov Kirill <kirill(at)linuxfocus.org>

2004-03-05, generated by lfparser version 2.43