"Fossies" - the Fresh Open Source Software Archive

Member "fsbackup-1.2pl2/scripts/fsrestore.sh" (12 Aug 2004, 1563 Bytes) of package /linux/privat/old/fsbackup-1.2pl2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 # Script for restore files backuped by fsbackup.pl
    3 # Восстановление данных из инкрементального бэкапа.
    4 # Внимание, данные предварительно должны быть расшифрованы в случае использования PGP
    5 #
    6 # http://www.opennet.ru/dev/fsbackup/
    7 # Copyright (c) 2001 by Maxim Chirkov. <mc@tyumen.ru>
    8 
    9 #-------------------
   10 # Name of backup, single word.
   11 # Имя бэкапа.
   12 #-------------------
   13 
   14 backup_name="test_host"
   15 
   16 
   17 #-------------------
   18 # Directory with content of incremental backup.
   19 # Директория где находится бэкап.
   20 #-------------------
   21 
   22 backup_path="/mnt/backup"
   23 
   24 
   25 #-------------------
   26 # Directory to save restored data.
   27 # Корневая директория куда будут помещены данные восстановленные из бэкапа.
   28 #-------------------
   29 
   30 restore_path="/var/backup" 
   31 
   32 
   33 ###########################################################################
   34 old_path=`pwd`
   35 cd $backup_path
   36 
   37 for cur_arc in `ls *.tar* | sort -n`; do
   38     del_file="`echo \"$cur_arc\"| sed 's/\-0.tar\(.gz\)*$//'`.del"
   39     dir_file="`echo \"$cur_arc\"| sed 's/\-0.tar\(.gz\)*$//'`.dir"
   40     if [ -e "$del_file" ]; then
   41             echo "Removing deleted files for $cur_arc..."
   42         cd $restore_path
   43         sh $backup_path/$del_file
   44         cd $backup_path
   45     fi
   46         echo "Restoring $cur_arc..."
   47     gzip_type=`ls $cur_arc|grep '.gz'`
   48     if [ -n "$gzip_type" ]; then
   49         tar -xpzf $cur_arc -C $restore_path
   50     else
   51         tar -xpf $cur_arc -C $restore_path
   52     fi
   53     if [ -e "$dir_file" ]; then
   54         echo "Fixing directory permissions for $cur_arc..."
   55         cd $restore_path
   56         sh $backup_path/$dir_file
   57         cd $backup_path
   58     fi
   59 done
   60 
   61 cd $old_path
   62 
   63