[go: up one dir, main page]

File: verify_src

package info (click to toggle)
kbackup 1.2.11-3
  • links: PTS
  • area: main
  • in suites: potato
  • size: 716 kB
  • ctags: 294
  • sloc: sh: 4,664; ansic: 1,595; makefile: 113; lisp: 37
file content (262 lines) | stat: -rw-r--r-- 7,525 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
#!/bin/sh
#
# $Header: /home/kbackup/CVSROOT/KBackup/src/verify_src,v 1.21 1997/09/19 19:49:25 kbackup Exp $
#
# This file is Copyright (C) 1995-1997 by Karsten Ballder (Ballueder@usa.net)
#
# It is part of the KBackup package, see the file COPYING for details.
# KBackup and all files included in this package are licensed and protected
# under the terms and conditions of the GNU General Public License Version 2.
#
#	If you want to contact the current maintainer of this software, please
#	send e-mail to: KBackup@usa.net
#
#
#	subroutine for verifying existing archives
#	uses read_data() for input
#
#

if [ "ReadData_src_loaded" != "YES" ]
then
	. $SRCDIR/$READDATA_SRC
fi

Verify_src_loaded=YES

Verify_II()	# accepts option "auto" to avoid insert-media-prompt
{
	save_options
	backup_filesperarchive="???"
	backup_version="???"
	backup_date="???"
	backup_compression="???"
	backup_type="???"
	backup_archive_format="???"
	backup_multivolume="???"
	backup_donly="???"
	backup_use_multibuf="???"
	backup_multibuf_seq_info="???"
	backup_multibuf_blksize="???"
	backup_multibuf_nblocks="???"
	backup_parent="???"
	backup_numversion=0
	
	old_compression="$compression"
	
	if [ "$device_type" = "FLOPPY" ]
	then
		ErrorBox "Verify for disk archives not implemented."
		return
	fi

	if [ "$1" != "auto" ]
	then
		insert_media
		if [ $? != 0 ] 
		then
			return
		fi
	fi	

	auto_rewind
	
	if [ "$device_type" = "TAPE" ]
	then
		InfoBox "Reading header..." 
		read_data -raw $device >$TMP/$TMPFILE 2>$STDERR
		check_error -dev
		if [ $? != 0 ]
		then
			return
		fi
		retry=2
		while [ $retry -gt 0 ]
		do
			read firstline < $TMP/$TMPFILE 
			if [ $? = 0 ] && [ "$firstline" = "#KBackup" ]
			then
				retry=0
				backup_use_multibuf="???"
				. $TMP/$TMPFILE
				compression="$backup_compression"
				if [ "$backup_use_multibuf" = "YES" ]
				then
					use_multibuf="$backup_use_multibuf"
					multibuf_blksize="$backup_multibuf_blksize"
					multibuf_nblocks="$backup_multibuf_nblocks"
					multibuf_seq_info="$backup_multibuf_seq_info"
				else
					use_multibuf=NO
				fi
			else
				if [ "$1" != "auto" ] || [ $retry -eq 1 ]
				then
					ErrorBox "No valid KBackup Archive Header."
					return
				else
					MsgBox \
"Cannot read archive header.
If this is a multivolume archive,
please insert the first volume!"
					retry=`expr $retry - 1`
				fi
			fi
		done # while retry	
		report "Verify: Archive header:     OK"
		
		dirstatus=
		archstatus=		
		$DIALOG   --title "Verify" --infobox "\n\
Archive created by KBackup Version: $backup_version\n\
  files per archive: .............. $backup_filesperarchive\n\
Creation date: .................... $backup_date\n\
Backup type: ...................... $backup_type\n\
Archive format: ................... $backup_archive_format\n\
Compression method: ............... $backup_compression\n\
Directories-only flag: ............ $backup_donly\n\
  using MultiBuf: ................. $backup_use_multibuf\n\
  MultiBuf blocksize: ............. $backup_multibuf_blksize\n\
  MultiBuf number of blocks: ...... $backup_multibuf_nblocks\n\
\n\
Parent directory of backup: ....... $backup_parent\n\
Contents directory: ............... $dirstatus\n\
Archive status: ................... $archstatus" 20 75 

case $backup_compression in
			GZIP) ;;
			COMPRESS) ;;
			NONE) ;;
			PGP) ;;
			*)	beep
				$DIALOG   --title "Error" --msgbox "\nNo KBackup archive or\nunknown compression method." 7 40
				backup_compression="???"
				restore_options
				return ;;
		esac
		if [ "$backup_compression" != "???" ] ; then
			compression="$backup_compression"
			set_compress
			if [ "$backup_compression" = "PGP" ]
			then
				GetPGPPASS
			fi
		fi

			$DIALOG   --title "Verify" --infobox "\n\
Archive created by KBackup Version: $backup_version\n\
  files per archive: .............. $backup_filesperarchive\n\
Creation date: .................... $backup_date\n\
Backup type: ...................... $backup_type\n\
Archive format: ................... $backup_archive_format\n\
Compression method: ............... $backup_compression\n\
Directories-only flag: ............ $backup_donly\n\
  using MultiBuf: ................. $backup_use_multibuf\n\
  MultiBuf blocksize: ............. $backup_multibuf_blksize\n\
  MultiBuf number of blocks: ...... $backup_multibuf_nblocks\n\
\n\
Parent directory of backup: ....... $backup_parent\n\
Contents directory: ............... $dirstatus\n\
Archive status: ................... $archstatus" 20 75 

(read_data | $uncompress )>/dev/null 2>$STDERR 3<$TMP/$PHRASEFILE </dev/null
		if check_compress_success
		then
			dirstatus=OK
			report "Verify: Contents directory: OK"
		else
			dirstatus=ERR
			report "Verify: Contents directory: Corrupted"
			beep
			$DIALOG   --title "Error" --yesno "\nContents directory corrupted.\nCheck archive contents anyway?" 8 40
			if [ $? != 0 ]
			then
				restore_options
				clear_PGP
				return
			fi
		fi
			$DIALOG   --title "Verify" --infobox "\n\
Archive created by KBackup Version: $backup_version\n\
  files per archive: .............. $backup_filesperarchive\n\
Creation date: .................... $backup_date\n\
Backup type: ...................... $backup_type\n\
Archive format: ................... $backup_archive_format\n\
Compression method: ............... $backup_compression\n\
Directories-only flag: ............ $backup_donly\n\
  using MultiBuf: ................. $backup_use_multibuf\n\
  MultiBuf blocksize: ............. $backup_multibuf_blksize\n\
  MultiBuf number of blocks: ...... $backup_multibuf_nblocks\n\
\n\
Parent directory of backup: ....... $backup_parent\n\
Contents directory: ............... $dirstatus\n\
Archive status: ................... $archstatus" 20 75 

		if [ $backup_archive_format = TAR ]
		then
			(read_data | $uncompress | $TAR $xopt -t -f -) 2>$STDERR >/dev/null 3<$TMP/$PHRASEFILE </dev/null
		else	# AFIO
			xopt=
			if [ "$device_type" = "FLOPPY" ]
			then
				blocks=`echo $floppy_format|$SED '1,$ s/\(.*\)\/.*/\1k/g' `
				xopt="$xopt -F -s $blocks "
			fi
	
			if [ "$compression" = "GZIP" ]
			then
				xopt="$xopt -Z"
				num=`echo $compress_options | $SED '1,$ s/-\([0-9]\).*/\1/g'`
				case "$num" in
				"0"|"1"|"2"|"4"|"5"|"6"|"7"|"8"|"9")
					xopt="$xopt -G $num"
					;;
				esac
			fi
			
			reset
			clear
			( read_data | $AFIO -t $xopt - ) 2>$STDERR 3<$TMP/$PHRASEFILE
			if [ $? != 0 ]
			then
				ErrorBox "Archive is corrupted."	
				restore_options
				clear_PGP	
				return
			fi
		fi

		if [ $? -eq 0 ]
		then
			archstatus=OK
		else
			archstatus=Corrupted
		fi
		
		report "Verify: Archive status:     $archstatus"


$DIALOG   --title "Verify" --msgbox "\n\
Archive created by KBackup Version: $backup_version\n\
  files per archive: .............. $backup_filesperarchive\n\
Creation date: .................... $backup_date\n\
Backup type: ...................... $backup_type\n\
Archive format: ................... $backup_archive_format\n\
Compression method: ............... $backup_compression\n\
Directories-only flag: ............ $backup_donly\n\
  using MultiBuf: ................. $backup_use_multibuf\n\
  MultiBuf blocksize: ............. $backup_multibuf_blksize\n\
  MultiBuf number of blocks: ...... $backup_multibuf_nblocks\n\
\n\
Parent directory of backup: ....... $backup_parent\n\
Contents directory: ............... $dirstatus\n\
Archive status: ................... $archstatus" 20 75 

else
		beep
		$DIALOG   --title "Error" --msgbox "\nThere's no verify for files." 7 40
	fi
	clear_PGP
	restore_options
}