]>
Dogcows Code - chaz/tar/blob - scripts/restore.in
2 # This program is part of GNU tar
3 # Copyright 2004, Free Software Foundation
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 1, or (at your option)
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 # Load library routines
21 SYSCONFDIR
=${SYSCONFDIR-@sysconfdir@}
22 .
${LIBDIR-@libexecdir@}/backup.sh
26 usage: $PROGNAME [OPTIONS] [PATTERN [PATTERN...]]
29 -a, --all Restore all filesystems.
30 -l, --level=LEVEL Start restoring from the given backup LEVEL
31 (default $DUMP_LEVEL).
32 -v, --verbose[=LEVEL] Set verbosity level. Default 100.
34 Informational options:
35 -h, --help Display this help message.
36 -L, --license Display program license.
37 -V, --version Display program version.
39 Send bug reports to @PACKAGE_BUGREPORT@.
49 if [ -z "$prev" ]; then
51 optarg
=`expr "x$opt" : 'x[^=]*=\(.*\)'`
61 --l=*|--le=*|--lev=*|--leve=*|--level=*)
64 -l|--l|--le|--lev|--leve|--level)
67 --verb=*|--verbo=*|--verbos=*|--verbose=*)
70 -v|--verb|--verbo|--verbos|--verbose)
73 -v*) VERBOSE
=`expr $option : "-v\(.*\)"`;;
74 -V|--v|--ve|--ver|--vers|--versi|--versio|--version)
75 echo "restore (@PACKAGE@ @VERSION@)"
77 -L|--li|--lic|--lice|--licen|--licens|--license)
80 -h|--h|--he|--hel|--help)
83 -*) bailout
"Unknown option $opt. Try $PROGNAME --help for more info.";;
84 *) if [ -z "$PATTERN" ]; then
87 PATTERN
="$PATTERN|$opt"
93 if [ -z "$RESTORE_ALL" ]; then
94 if [ -z "$PATTERN" ]; then
102 This file contains any messages produced by $PROGNAME.
104 It was created by GNU $PROGNAME, from @PACKAGE@ (@VERSION@).
105 Invocation command line was
113 fs
="`echo \"${1}\" | sed -e 's/^.*://'`"
114 fsname
="`echo \"${1}\" | sed -e 's/\//:/g'`"
115 remotehost
="`expr \"${1}\" : '\([^/][^/]*\):.*'`"
116 if [ -z "$remotehost" ]; then
117 remotehost
=$localhost
120 message
10 "fsname=$fsname"
121 message
10 "remotehost=$remotehost"
123 LOGPAT
="`level_log_name ${fsname} '[0-9]'`"
124 PREFIX
="`level_log_name ${fsname} ''`"
125 message
10 LOGPAT
=$LOGPAT
126 message
10 PREFIX
=$PREFIX
127 LEVELS
=`remote_run "${remotehost}" ls $LOGPAT |
128 sed "s,$PREFIX,," | sort -n`
129 message
10 "LEVELS=$LEVELS"
131 echo "Starting restore of ${1} at level $DUMP_LEVEL."
134 if [ $level -lt $DUMP_LEVEL ]; then
135 message
10 "Skipping level $level"
138 message
10 "Restoring level $level"
140 DATE
=`get_dump_time $level`
141 FILE
="`level_log_name ${fsname} ${level}`"
142 message
10 "FILE=$FILE"
144 LABEL
="`print_level $level` backup of ${fs} on ${remotehost} at ${DATE}"
145 ${RESTORE_BEGIN-:} $level $remotehost $fs $fsname
146 backup_host
${remotehost} \
147 "--listed=\"$FILE\"" \
148 "--label=\"$LABEL\"" \
150 ${RESTORE_END-:} $level $remotehost $fs $fsname
156 LOGPAT
="`level_log_name MISC '[0-9]'`"
157 PREFIX
="`level_log_name MISC ''`"
158 message
10 LOGPAT
=$LOGPAT
159 message
10 PREFIX
=$PREFIX
160 LEVELS
=`remote_run "${localhost}" ls $LOGPAT | sed "s,$PREFIX,," | sort -n`
161 message
10 "LEVELS=$LEVELS"
163 echo "Starting restore of miscellaneous files at level $DUMP_LEVEL."
166 if [ $level -lt $DUMP_LEVEL ]; then
167 message
10 "Skipping level $level"
170 message
10 "Restoring level $level"
172 DATE
=`get_dump_time $level`
173 FILE
="`level_log_name MISC ${level}`"
174 message
10 "FILE=$FILE"
176 LABEL
="`print_level $level` backup of miscellaneous files at ${DATE}"
177 ${RESTORE_BEGIN-:} $level $localhost MISC MISC
178 backup_host
${localhost} \
179 "--listed=\"$FILE\"" \
180 "--label=\"$LABEL\"" \
182 ${RESTORE_END-:} $level $localhost MISC MISC
186 # Operation Overwiew:
188 # 1. Determine the time of the last backup
189 # 2. Create list of incremental listings to process
190 # 3. For each filesystem:
191 # 3.1. Start at the requested dump level (default 0) and proceed up to
192 # the last available level:
193 # 3.1.1 Deduce the volume label
194 # 3.1.2. Invoke [rsh] tar --listed=FILE --label=LABEL [opts] -xf $TAPE_FILE
197 (message
1 "Preparing for restore"
199 message
1 "processing backup directories"
201 for dir
in ${BACKUP_DIRS}
203 message
1 "Processing $dir"
205 ${PATTERN-*}) restore_fs
$dir;;
209 if [ "x${BACKUP_FILES}" != "x" ] ; then
210 message
1 "processing miscellaneous files"
211 if [ -z "$PATTERN" ]; then
215 for file in ${BACKUP_FILES}
217 rel_file
=`expr $file : '/\(.*\)'`
219 $PATTERN) if [ -z "$RESTORE_FILES" ]; then
220 RESTORE_FILES
="$rel_file"
222 RESTORE_FILES
="$RESTORE_FILES $rel_file"
226 [ -z "$RESTORE_FILES" ] || restore_files
$RESTORE_FILES
229 fi) 2>&1 | tee -a "${LOGFILE}"
This page took 0.045855 seconds and 4 git commands to generate.