source: MondoRescue/branches/3.3/mondo/src/common/libmondo-verify.c@ 3876

Last change on this file since 3876 was 3871, checked in by Bruno Cornec, 4 months ago

Fix syntax issues

  • Property svn:keywords set to Id
File size: 35.5 KB
RevLine 
[1]1/***************************************************************************
[2211]2$Id: libmondo-verify.c 3871 2024-03-07 17:06:33Z bruno $
[1]3***************************************************************************/
4
5
6/**
7 * @file
8 * Functions for verifying backups (booted from hard drive, not CD).
9 */
10
11#include "my-stuff.h"
[2211]12#include "mr_mem.h"
[1]13#include "mondostructures.h"
[541]14#include "libmondo-gui-EXT.h"
[1]15#include "libmondo-files-EXT.h"
16#include "libmondo-fork-EXT.h"
17#include "libmondo-stream-EXT.h"
18#include "libmondo-string-EXT.h"
19#include "libmondo-devices-EXT.h"
20#include "libmondo-tools-EXT.h"
21
[3871]22
[1]23/*@unused@*/
[117]24//static char cvsid[] = "$Id: libmondo-verify.c 3871 2024-03-07 17:06:33Z bruno $";
[1]25
26/**
27 * The number of the most recently verified afioball.
28 * @ingroup globalGroup
29 */
30int g_last_afioball_number = -1;
31
[948]32extern char *g_getfacl;
33extern char *g_getfattr;
[1316]34extern char *MONDO_LOGFILE;
[1]35
[1645]36/* Reference to global bkpinfo */
37extern struct s_bkpinfo *bkpinfo;
38
[1648]39
[1]40/**
[1648]41 * Generate the filename of a tarball to verify.
42 * @param bkpinfo The backup information structure. @c bkpinfo->zip_suffix is the only field used.
43 * @param mountpoint The directory where the CD/DVD/ISO is mounted.
44 * @param setno The afioball number to get the location of.
45 * @return The absolute path to the afioball.
46 * @note The returned string points to static data that will be overwritten with each call.
47 * @ingroup stringGroup
48 */
49char *vfy_tball_fname(char *mountpoint, int setno)
50{
51 /*@ buffers ******************************************************* */
52 static char output[MAX_STR_LEN];
53
54 assert(bkpinfo != NULL);
55 assert_string_is_neither_NULL_nor_zerolength(mountpoint);
[3191]56 sprintf(output, "%s/archives/%d.star.%s", mountpoint, setno, bkpinfo->zip_suffix);
[1648]57 if (!does_file_exist(output)) {
[3191]58 sprintf(output, "%s/archives/%d.afio.%s", mountpoint, setno, bkpinfo->zip_suffix);
[1648]59 }
60 return (output);
61}
62
63
64/**
[1]65 * Generate a list of the files that have changed, based on @c afio @c -r
66 * messages.
67 * @param changedfiles_fname Filename of the place to put a list of afio's reported changed.
68 * @param ignorefiles_fname Filename of a list of files to ignore (use "" if none).
69 * @param stderr_fname File containing afio's stderr output.
70 * @return The number of differences found (0 for a perfect backup).
71 * @bug This function seems orphaned.
72 * @ingroup utilityGroup
73 */
74long
[128]75generate_list_of_changed_files(char *changedfiles_fname,
76 char *ignorefiles_fname, char *stderr_fname)
[1]77{
[128]78 /*@ buffer ********************************************************** */
[3191]79 char *command = NULL;
80 char *afio_found_changes = NULL;
[1]81
[128]82 /*@ int ************************************************************* */
83 int res = 0;
[1]84
[128]85 /*@ long ************************************************************ */
86 long afio_diffs = 0;
[1]87
[128]88 assert_string_is_neither_NULL_nor_zerolength(changedfiles_fname);
89 assert_string_is_neither_NULL_nor_zerolength(ignorefiles_fname);
90 assert_string_is_neither_NULL_nor_zerolength(stderr_fname);
[1]91
[3191]92 mr_asprintf(afio_found_changes, "%s.afio", ignorefiles_fname);
93 sync();
[128]94
95 log_msg(1, "Now scanning log file for 'afio: ' stuff");
[3191]96 mr_asprintf(command, "grep \"afio: \" %s | sed 's/afio: //' | grep -vE '^/dev/.*$' >> %s", stderr_fname, afio_found_changes);
[128]97 log_msg(2, command);
98 res = system(command);
[3191]99 mr_free(command);
100
[128]101 if (res) {
102 log_msg(2, "Warning - failed to think");
103 }
104
105 log_msg(1, "Now scanning log file for 'star: ' stuff");
[3191]106 mr_asprintf(command, "grep \"star: \" %s | sed 's/star: //' | grep -vE '^/dev/.*$' >> %s", stderr_fname, afio_found_changes);
[128]107 log_msg(2, command);
108 res = system(command);
[3191]109 mr_free(command);
110
[128]111 if (res) {
112 log_msg(2, "Warning - failed to think");
113 }
114 afio_diffs = count_lines_in_file(afio_found_changes);
[3191]115 mr_asprintf(command, "sort %s %s %s | uniq -c | awk '{ if ($1==\"2\") {print $2;};}' | grep -v \"incheckentry xwait()\" > %s", ignorefiles_fname, afio_found_changes, afio_found_changes, changedfiles_fname);
116 mr_free(afio_found_changes);
[128]117 log_msg(2, command);
118 paranoid_system(command);
[3191]119 mr_free(command);
[128]120 return (afio_diffs);
[1]121}
122
123
124/**
125 * @addtogroup LLverifyGroup
126 * @{
127 */
128/**
129 * Verify all afioballs stored on the inserted CD (or an ISO image).
130 * @param bkpinfo The backup information structure. @c bkpinfo->backup_media_type
131 * is used in this function, and the structure is also passed to verify_an_afioball_from_CD().
132 * @param mountpoint The location the CD/DVD/ISO is mounted on.
133 * @return The number of sets containing differences (0 for success).
134 */
[1645]135int verify_afioballs_on_CD(char *mountpoint)
[1]136{
137
[128]138 /*@ buffers ********************************************************* */
[3191]139 char *tmp = NULL;
[2242]140 char *mds = NULL;
[1]141
[128]142 /*@ int ************************************************************* */
143 int set_number = 0;
[1]144 int retval = 0;
145 int total_sets = 0;
146 int percentage = 0;
147
[128]148 assert_string_is_neither_NULL_nor_zerolength(mountpoint);
149 assert(bkpinfo != NULL);
150
151 for (set_number = 0;
152 set_number < 9999
153 &&
[1645]154 !does_file_exist(vfy_tball_fname(mountpoint, set_number));
[128]155 set_number++);
[1645]156 if (!does_file_exist(vfy_tball_fname(mountpoint, set_number))) {
[128]157 return (0);
[1]158 }
[128]159
160 if (g_last_afioball_number != set_number - 1) {
161 if (set_number == 0) {
[3191]162 log_msg(1, "Weird error in verify_afioballs_on_CD() but it's really a cosmetic error, nothing more");
[128]163 } else {
164 retval++;
[3191]165 log_to_screen("Warning - missing set(s) between %d and %d\n", g_last_afioball_number, set_number - 1);
[128]166 }
167 }
[2242]168 mds = media_descriptor_string(bkpinfo->backup_media_type);
[3191]169 mr_asprintf(tmp, "Verifying %s #%d's tarballs", mds, g_current_media_number);
[2242]170 mr_free(mds);
171
[128]172 open_evalcall_form(tmp);
[3191]173 mr_free(tmp);
[128]174
175 for (total_sets = set_number;
[1645]176 does_file_exist(vfy_tball_fname(mountpoint, total_sets));
[128]177 total_sets++) {
178 log_msg(1, "total_sets = %d", total_sets);
179 }
180 for (;
[1645]181 does_file_exist(vfy_tball_fname(mountpoint, set_number));
[128]182 set_number++) {
183 percentage =
184 (set_number - g_last_afioball_number) * 100 / (total_sets -
185 g_last_afioball_number);
186 update_evalcall_form(percentage);
187 log_msg(1, "set = %d", set_number);
188 retval +=
[1645]189 verify_an_afioball_from_CD(vfy_tball_fname(mountpoint, set_number));
[128]190 }
191 g_last_afioball_number = set_number - 1;
192 close_evalcall_form();
193 return (retval);
[1]194}
195
196/**
197 * Verify all slices stored on the inserted CD (or a mounted ISO image).
198 * @param bkpinfo The backup information structure. Fields used:
199 * - @c compression_level
200 * - @c restore_path
201 * - @c use_lzo
202 * - @c zip_exe
203 * - @c zip_suffix
204 * @param mtpt The mountpoint the CD/DVD/ISO is mounted on.
205 * @return The number of differences (0 for perfect biggiefiles).
206 */
[1645]207int verify_all_slices_on_CD(char *mtpt)
[1]208{
209
[128]210 /*@ buffer ********************************************************** */
[3191]211 char *tmp = NULL;
212 char *mountpoint = NULL;
213 char *command = NULL;
[2242]214 char *mds = NULL;
[3191]215 char *sz_exe = NULL;
[128]216 static char *bufblkA = NULL;
217 static char *bufblkB = NULL;
218 const long maxbufsize = 65536L;
219 long currsizA = 0;
220 long currsizB = 0;
221 long j;
[1]222
[128]223 /*@ long ************************************************************ */
224 long bigfile_num = 0;
225 long slice_num = -1;
226 int res;
[1]227
[128]228 static FILE *forig = NULL;
229 static struct s_filename_and_lstat_info biggiestruct;
230 static long last_bigfile_num = -1;
231 static long last_slice_num = -1;
232 FILE *pin;
233 FILE *fin;
234 int retval = 0;
[1]235
[128]236 if (!bufblkA) {
237 if (!(bufblkA = malloc(maxbufsize))) {
238 fatal_error("Cannot malloc bufblkA");
239 }
240 }
241 if (!bufblkB) {
242 if (!(bufblkB = malloc(maxbufsize))) {
243 fatal_error("Cannot malloc bufblkB");
244 }
245 }
[1]246
[128]247 assert(bkpinfo != NULL);
248 assert_string_is_neither_NULL_nor_zerolength(mtpt);
[1]249
[128]250 if (bkpinfo->compression_level > 0) {
251 if (bkpinfo->use_lzo) {
[3191]252 mr_asprintf(sz_exe, "lzop");
[1003]253 } else if (bkpinfo->use_gzip) {
[3191]254 mr_asprintf(sz_exe, "gzip");
255 } else if (bkpinfo->use_lzma) {
256 mr_asprintf(sz_exe, "lzma");
[128]257 } else {
[3191]258 mr_asprintf(sz_exe, "bzip2");
[128]259 }
260 }
[1]261
[2230]262 log_it("before vsbf");
[2242]263 mds = media_descriptor_string(bkpinfo->backup_media_type);
[3191]264 mr_asprintf(tmp, "Verifying %s#%d's big files", mds, g_current_media_number);
[2242]265 mr_free(mds);
266
[128]267 open_evalcall_form(tmp);
[3191]268 mr_free(tmp);
269
[2230]270 log_it("after vsbf");
[3191]271 mr_asprintf(mountpoint, "%s/archives", mtpt);
[128]272 if (last_bigfile_num == -1) {
273 bigfile_num = 0;
274 slice_num = 0;
275 } else if (slice_num == 0) {
276 bigfile_num = last_bigfile_num + 1;
277 slice_num = 0;
278 } else {
279 bigfile_num = last_bigfile_num;
280 slice_num = last_slice_num + 1;
281 }
[3830]282 while (does_file_exist(slice_fname(bigfile_num, slice_num, mountpoint, bkpinfo->zip_suffix))) {
[1236]283 // handle slices until end of CD
[128]284 if (slice_num == 0) {
[3191]285 log_msg(2, "ISO=%d bigfile=%ld --START--", g_current_media_number, bigfile_num);
286 if (! (fin = fopen(slice_fname(bigfile_num, slice_num, mountpoint, ""), "r"))) {
[128]287 log_msg(2, "Cannot open bigfile's info file");
288 } else {
[3191]289 if (fread ((void *) &biggiestruct, 1, sizeof(biggiestruct), fin) < sizeof(biggiestruct)) {
[128]290 log_msg(2, "Unable to get biggiestruct");
291 }
292 paranoid_fclose(fin);
293 }
[3828]294 if (bkpinfo->restore_path != NULL) {
[3191]295 mr_asprintf(tmp, "%s/%s", bkpinfo->restore_path, biggiestruct.filename);
296 log_msg(2, "Opening biggiefile #%ld - '%s'", bigfile_num, tmp);
297 forig = fopen(tmp, "r");
298 mr_free(tmp);
299
300 if (!forig) {
301 log_msg(2, "Failed to open bigfile. Darn.");
302 log_to_screen("%s/%s not found on live filesystem", bkpinfo->restore_path, biggiestruct.filename);
303 mr_asprintf(tmp, "echo \"%s/%s not found\" >> %s/biggies.changed", bkpinfo->restore_path, biggiestruct.filename, bkpinfo->tmpdir);
304 paranoid_system(tmp);
305 mr_free(tmp);
[1236]306
[3191]307 bigfile_num++;
308 slice_num = 0;
309 retval++;
310 } else {
311 slice_num++;
312 }
[1236]313 } else {
[3191]314 log_it("Unable to open bigfile as restore_path is NULL");
[128]315 }
[1236]316 } else if (does_file_exist(slice_fname(bigfile_num, slice_num, mountpoint, "")) &&
317 (length_of_file(slice_fname(bigfile_num, slice_num, mountpoint, "")) == 0)) {
[128]318 log_msg(2, "ISO=%d bigfile=%ld ---END---",
319 g_current_media_number, bigfile_num);
320 bigfile_num++;
321 paranoid_fclose(forig);
322 slice_num = 0;
323 } else {
[3191]324 log_msg(2, "ISO=%d bigfile=%ld slice=%ld", g_current_media_number, bigfile_num, slice_num);
325 if ((!does_file_exist(slice_fname(bigfile_num, slice_num, mountpoint, ""))) && (sz_exe != NULL)) {
326 mr_asprintf(command, "%s -dc %s 2>> %s", sz_exe, slice_fname(bigfile_num, slice_num, mountpoint, bkpinfo->zip_suffix), MONDO_LOGFILE);
[128]327 } else {
[3191]328 mr_asprintf(command, "cat %s 2>> %s", slice_fname(bigfile_num, slice_num, mountpoint, ""), MONDO_LOGFILE);
[128]329 }
[3191]330 pin = popen(command, "r");
331 mr_free(command);
332 if (pin) {
[128]333 res = 0;
334 while (!feof(pin)) {
335 currsizA = fread(bufblkA, 1, maxbufsize, pin);
336 if (currsizA <= 0) {
337 break;
338 }
339 currsizB = fread(bufblkB, 1, currsizA, forig);
340 if (currsizA != currsizB) {
341 res++;
342 } else {
343 for (j = 0;
344 j < currsizA && bufblkA[j] == bufblkB[j];
345 j++);
346 if (j < currsizA) {
347 res++;
348 }
349 }
350 }
351 paranoid_pclose(pin);
[1236]352 if (res && !strncmp(biggiestruct.filename, "/dev/", 5)) {
[128]353 log_msg(3,
[296]354 "Ignoring differences between %s and live filesystem because it's a device and therefore the archives are stored via ntfsclone, not dd.",
[128]355 biggiestruct.filename);
356 log_msg(3,
357 "If you really want verification for %s, please contact the devteam and offer an incentive.",
358 biggiestruct.filename);
359 res = 0;
360 }
361 if (res) {
362 log_msg(0,
363 "afio: \"%s\": Corrupt biggie file, says libmondo-archive.c",
364 biggiestruct.filename);
365 retval++;
366 }
367 }
368 slice_num++;
369 }
[1]370 }
[3191]371 mr_free(mountpoint);
372 mr_free(sz_exe);
373
[128]374 last_bigfile_num = bigfile_num;
375 last_slice_num = slice_num - 1;
376 if (last_slice_num < 0) {
377 last_bigfile_num--;
[1]378 }
[128]379 close_evalcall_form();
380 if (bufblkA) {
381 paranoid_free(bufblkA);
[1]382 }
[128]383 if (bufblkB) {
384 paranoid_free(bufblkB);
385 }
386 return (0);
[1]387}
388
389
390
391
392
393
394/**
395 * Verify one afioball from the CD.
396 * You should be changed to the root directory (/) for this to work.
397 * @param bkpinfo The backup information structure. Fields used:
398 * - @c bkpinfo->use_lzo
399 * - @c bkpinfo->tmpdir
400 * - @c bkpinfo->zip_exe
401 * - @c bkpinfo->zip_suffix
402 * @param tarball_fname The filename of the afioball to verify.
403 * @return 0, always.
404 */
[1645]405int verify_a_tarball(char *tarball_fname)
[1]406{
[128]407 /*@ buffers ********************************************************* */
[3191]408 char *command = NULL;
409 char *outlog = NULL;
410 char *tmp = NULL;
[1]411
[128]412 /*@ pointers ******************************************************* */
413 FILE *pin;
[1]414
[128]415 /*@ long *********************************************************** */
416 long diffs = 0;
[1]417
[128]418 assert(bkpinfo != NULL);
419 assert_string_is_neither_NULL_nor_zerolength(tarball_fname);
[1]420
[128]421 log_it("Verifying fileset '%s'", tarball_fname);
[3191]422 mr_asprintf(outlog, "%s/afio.log", bkpinfo->tmpdir);
423 /* if programmer forgot to say which compression thingy to use then find out */
424 if (strstr(tarball_fname, ".lzo") && strcmp(bkpinfo->zip_suffix, "lzo")) {
[128]425 log_msg(2, "OK, I'm going to start using lzop.");
[3830]426 mr_free(bkpinfo->zip_exe);
427 mr_free(bkpinfo->zip_suffix);
428 mr_asprintf(bkpinfo->zip_exe, "%s", "lzop");
429 mr_asprintf(bkpinfo->zip_suffix, "%s", "lzo");
[128]430 bkpinfo->use_lzo = TRUE;
[998]431 bkpinfo->use_gzip = FALSE;
[3191]432 bkpinfo->use_lzma = FALSE;
[128]433 }
[3191]434 if (strstr(tarball_fname, ".gz") && strcmp(bkpinfo->zip_suffix, "gz")) {
[998]435 log_msg(2, "OK, I'm going to start using gzip.");
[3830]436 mr_free(bkpinfo->zip_exe);
437 mr_free(bkpinfo->zip_suffix);
438 mr_asprintf(bkpinfo->zip_exe, "%s", "gzip");
439 mr_asprintf(bkpinfo->zip_suffix, "%s", "gz");
[998]440 bkpinfo->use_lzo = FALSE;
441 bkpinfo->use_gzip = TRUE;
[3191]442 bkpinfo->use_lzma = FALSE;
[998]443 }
[3191]444 if (strstr(tarball_fname, ".bz2") && strcmp(bkpinfo->zip_suffix, "bz2")) {
[128]445 log_msg(2, "OK, I'm going to start using bzip2.");
[3830]446 mr_free(bkpinfo->zip_exe);
447 mr_free(bkpinfo->zip_suffix);
448 mr_asprintf(bkpinfo->zip_exe, "%s", "bzip2");
449 mr_asprintf(bkpinfo->zip_suffix, "%s", "bz2");
[128]450 bkpinfo->use_lzo = FALSE;
[998]451 bkpinfo->use_gzip = FALSE;
[3191]452 bkpinfo->use_lzma = FALSE;
[128]453 }
[3830]454 if (strstr(tarball_fname, ".xz") && strcmp(bkpinfo->zip_suffix, "xz")) {
[3191]455 log_msg(2, "OK, I'm going to start using lzma.");
[3830]456 mr_free(bkpinfo->zip_exe);
457 mr_free(bkpinfo->zip_suffix);
458 mr_asprintf(bkpinfo->zip_exe, "%s", "xz");
459 mr_asprintf(bkpinfo->zip_suffix, "%s", "xz");
[3191]460 bkpinfo->use_lzo = FALSE;
461 bkpinfo->use_gzip = FALSE;
462 bkpinfo->use_lzma = TRUE;
463 }
[3830]464 // As suffix is used even when no compression make it non-NULL
[3191]465 if (bkpinfo->zip_suffix == NULL) {
[3830]466 mr_asprintf(bkpinfo->zip_suffix, "%s", "");
[3191]467 }
[128]468 unlink(outlog);
469 if (strstr(tarball_fname, ".star")) {
470 bkpinfo->use_star = TRUE;
471 if (strstr(tarball_fname, ".bz2"))
[3191]472 mr_asprintf(command, "star -sparse -diff diffopts=mode,size,data file=%s %s >> %s 2>> %s", tarball_fname, (strstr(tarball_fname, ".bz2")) ? "-bz" : " ", outlog, outlog);
[128]473 } else {
474 bkpinfo->use_star = FALSE;
[3191]475 /* Here we suppose that there is always a compression program called */
476 if (bkpinfo->zip_exe) {
477 mr_asprintf(command, "afio -r -P %s -Z %s >> %s 2>> %s", bkpinfo->zip_exe, tarball_fname, outlog, outlog);
478 } else {
479 mr_asprintf(command, "afio -r -Z %s >> %s 2>> %s", tarball_fname, outlog, outlog);
480 }
[128]481 }
482 log_msg(6, "command=%s", command);
483 paranoid_system(command);
[3191]484 mr_free(command);
485
[128]486 if (length_of_file(outlog) < 10) {
[3191]487 mr_asprintf(command, "cat %s >> %s", outlog, MONDO_LOGFILE);
[128]488 } else {
[3191]489 mr_asprintf(command, "cut -d: -f%d %s | sort -u", (bkpinfo->use_star) ? 1 : 2, outlog);
[128]490 pin = popen(command, "r");
491 if (pin) {
[3191]492 for (mr_getline(tmp, pin); !feof(pin); mr_getline(tmp, pin)) {
[128]493 if (bkpinfo->use_star) {
494 if (!strstr(tmp, "diffopts=")) {
[3191]495 while (strlen(tmp) > 0 && tmp[strlen(tmp) - 1] < 32) {
[128]496 tmp[strlen(tmp) - 1] = '\0';
497 }
498 if (strchr(tmp, '/')) {
499 if (!diffs) {
[3191]500 log_msg(0, "'%s' - differences found", tarball_fname);
[128]501 }
[3191]502 log_msg(0, "star: /%s", strip_afio_output_line(tmp));
[128]503 diffs++;
504 }
505 }
506 } else {
507 if (!diffs) {
[3191]508 log_msg(0, "'%s' - differences found", tarball_fname);
[128]509 }
510 log_msg(0, "afio: /%s", strip_afio_output_line(tmp));
511 diffs++;
512 }
[3191]513 mr_free(tmp);
[1]514 }
[3191]515 mr_free(tmp);
[128]516 paranoid_pclose(pin);
517 } else {
518 log_OS_error(command);
519 }
520 }
[3191]521 mr_free(command);
522 mr_free(outlog);
[128]523 return (0);
[1]524}
525
526
527
528
529
530
531/**
532 * Verify one afioball from the CD.
533 * Checks for existence (calls fatal_error() if it does not exist) and
534 * then calls verify_an_afioball().
535 * @param bkpinfo The backup information structure. Passed to verify_an_afioball().
536 * @param tarball_fname The filename of the afioball to verify.
537 * @return The return value of verify_an_afioball().
538 * @see verify_an_afioball
539 */
540int
[1645]541verify_an_afioball_from_CD(char *tarball_fname)
[1]542{
543
[128]544 /*@ int ************************************************************* */
545 int res = 0;
[1]546
[128]547 assert_string_is_neither_NULL_nor_zerolength(tarball_fname);
[1]548
[128]549 log_msg(1, "Verifying %s", tarball_fname);
550 if (!does_file_exist(tarball_fname)) {
551 fatal_error("Cannot verify nonexistent afioball");
552 }
[1645]553 res = verify_a_tarball(tarball_fname);
[128]554 return (res);
[1]555}
556
557
558/**
559 * Verify one afioball from the opened tape/CD stream.
560 * Copies the file from tape to tmpdir and then calls verify_an_afioball().
561 * @param bkpinfo The backup information structure. Passed to verify_an_afioball().
562 * @param orig_fname The original filename of the afioball to verify.
563 * @param size The size of the afioball to verify.
564 * @return The return value of verify_an_afioball().
565 * @see verify_an_afioball
566 */
567int
[1645]568verify_an_afioball_from_stream(char *orig_fname, long long size)
[1]569{
570
[128]571 /*@ int ************************************************************** */
572 int retval = 0;
[1]573 int res = 0;
574
[128]575 /*@ buffers ********************************************************** */
[3191]576 char *tmp = NULL;
577 char *tarball_fname = NULL;
[1]578
[128]579 /*@ pointers ********************************************************* */
580 char *p;
[1]581
[128]582 assert(bkpinfo != NULL);
583 assert_string_is_neither_NULL_nor_zerolength(orig_fname);
[1]584
[128]585 p = strrchr(orig_fname, '/');
586 if (!p) {
587 p = orig_fname;
588 } else {
589 p++;
590 }
[3191]591 mr_asprintf(tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir);
[128]592 paranoid_system(tmp);
[3191]593 mr_free(tmp);
594
595 mr_asprintf(tarball_fname, "%s/tmpfs/temporary-%s", bkpinfo->tmpdir, p);
[1645]596 read_file_from_stream_to_file(tarball_fname, size);
597 res = verify_a_tarball(tarball_fname);
[128]598 if (res) {
[3191]599 log_msg(0, "Afioball '%s' no longer matches your live filesystem", p);
[128]600 retval++;
601 }
602 unlink(tarball_fname);
[3191]603 mr_free(tarball_fname);
[128]604 return (retval);
[1]605}
606
607
608/**
609 * Verify one biggiefile form the opened tape/CD stream.
610 * @param bkpinfo The backup information structure. @c bkpinfo->tmpdir is the only field used.
611 * @param biggie_fname The filename of the biggiefile to verify.
612 * @param size The size in bytes of said biggiefile.
613 * @return 0 for success (even if the file doesn't match); nonzero for a tape error.
614 */
615int
[1645]616verify_a_biggiefile_from_stream(char *biggie_fname, long long size)
[1]617{
618
[128]619 /*@ int ************************************************************* */
620 int retval = 0;
[1]621 int res = 0;
622 int current_slice_number = 0;
623 int ctrl_chr = '\0';
624
[128]625 /*@ char ************************************************************ */
[3191]626 char *test_file = NULL;
627 char *biggie_cksum = NULL;
628 char *orig_cksum = NULL;
629 char *tmp = NULL;
630 char *slice_fnam = NULL;
[128]631
632 /*@ pointers ******************************************************** */
[1]633 char *p;
634
[128]635 /*@ long long ******************************************************* */
636 long long slice_siz;
[1]637
[128]638 malloc_string(slice_fnam);
639 assert(bkpinfo != NULL);
640 assert_string_is_neither_NULL_nor_zerolength(biggie_fname);
[1]641
[128]642 p = strrchr(biggie_fname, '/');
643 if (!p) {
644 p = biggie_fname;
645 } else {
646 p++;
647 }
[3191]648 mr_asprintf(test_file, "%s/temporary-%s", bkpinfo->tmpdir, p);
[128]649 for (res =
650 read_header_block_from_stream(&slice_siz, slice_fnam, &ctrl_chr);
651 ctrl_chr != BLK_STOP_A_BIGGIE;
652 res =
[3191]653 read_header_block_from_stream(&slice_siz, slice_fnam, &ctrl_chr)) {
[128]654 if (ctrl_chr != BLK_START_AN_AFIO_OR_SLICE) {
655 wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr);
656 }
[1645]657 res = read_file_from_stream_to_file(test_file, slice_siz);
[128]658 unlink(test_file);
659 res =
[3191]660 read_header_block_from_stream(&slice_siz, slice_fnam, &ctrl_chr);
[128]661 if (ctrl_chr != BLK_STOP_AN_AFIO_OR_SLICE) {
662 log_msg(2, "test_file = %s", test_file);
663 wrong_marker(BLK_STOP_AN_AFIO_OR_SLICE, ctrl_chr);
664 }
665 current_slice_number++;
666 retval += res;
[1]667 }
[3191]668 mr_asprintf(biggie_cksum, "%s", slice_fnam);
[128]669 if (biggie_cksum[0] != '\0') {
[3191]670 mr_asprintf(orig_cksum, "%s", calc_checksum_of_file(biggie_fname));
[128]671 if (strcmp(biggie_cksum, orig_cksum)) {
[3191]672 log_msg(2, "orig cksum=%s; curr cksum=%s", biggie_cksum, orig_cksum);
673 log_to_screen("%s has changed on live filesystem", biggie_fname);
674
675 mr_asprintf(tmp, "echo \"%s\" >> %s/biggies.changed", biggie_fname, bkpinfo->tmpdir);
[3060]676 paranoid_system(tmp);
[3191]677 mr_free(tmp);
[128]678 }
[3191]679 mr_free(orig_cksum);
[1]680 }
[3191]681 mr_free(biggie_cksum);
682 mr_free(test_file);
[128]683 paranoid_free(slice_fnam);
684 return (retval);
[1]685}
686
687
688/**
689 * Verify all afioballs from the opened tape/CD stream.
690 * @param bkpinfo The backup information structure. Fields used:
691 * - @c bkpinfo->tmpdir
692 *
693 * @return 0 for success (even if there are differences); nonzero for a tape error.
694 */
[1645]695int verify_afioballs_from_stream()
[1]696{
[128]697 /*@ int ********************************************************** */
698 int retval = 0;
[1]699 int res = 0;
700 long current_afioball_number = 0;
701 int ctrl_chr = 0;
702 int total_afioballs = 0;
703
[128]704 /*@ buffers ***************************************************** */
[3191]705 char *tmp = NULL;
[1]706 char *fname;
[128]707 char *curr_xattr_list_fname;
708 char *curr_acl_list_fname;
[1]709
[128]710 /*@ long long *************************************************** */
711 long long size = 0;
[1]712
[128]713 assert(bkpinfo != NULL);
714 malloc_string(fname);
715 malloc_string(curr_xattr_list_fname);
716 malloc_string(curr_acl_list_fname);
[1]717
[948]718 if (g_getfattr) {
719 sprintf(curr_xattr_list_fname, XATTR_BIGGLST_FNAME_RAW_SZ,
[128]720 bkpinfo->tmpdir);
[948]721 }
722 if (g_getfacl) {
723 sprintf(curr_acl_list_fname, ACL_BIGGLST_FNAME_RAW_SZ,
[128]724 bkpinfo->tmpdir);
[948]725 }
[541]726 log_to_screen("Verifying regular archives on tape");
[1645]727 total_afioballs = get_last_filelist_number() + 1;
[541]728 open_progress_form("Verifying filesystem",
729 "I am verifying archives against your live filesystem now.",
730 "Please wait. This may take a couple of hours.", "",
[128]731 total_afioballs);
732 res = read_header_block_from_stream(&size, fname, &ctrl_chr);
733 if (ctrl_chr != BLK_START_AFIOBALLS) {
[2230]734 log_it("YOU SHOULD NOT GET HERE");
735 log_it("Grabbing the EXAT files");
[128]736 if (ctrl_chr == BLK_START_EXTENDED_ATTRIBUTES) {
[3116]737 res = read_EXAT_files_from_tape(&size, fname, &ctrl_chr,
[128]738 curr_xattr_list_fname,
739 curr_acl_list_fname);
740 }
[1]741 }
[128]742 if (ctrl_chr != BLK_START_AFIOBALLS) {
743 wrong_marker(BLK_START_AFIOBALLS, ctrl_chr);
[1]744 }
[128]745
746 for (res = read_header_block_from_stream(&size, fname, &ctrl_chr);
747 ctrl_chr != BLK_STOP_AFIOBALLS;
748 res = read_header_block_from_stream(&size, fname, &ctrl_chr)) {
[948]749 if (g_getfattr) {
750 sprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
[128]751 bkpinfo->tmpdir, current_afioball_number);
[948]752 }
753 if (g_getfacl) {
754 sprintf(curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
[128]755 bkpinfo->tmpdir, current_afioball_number);
[948]756 }
[128]757 if (ctrl_chr == BLK_START_EXTENDED_ATTRIBUTES) {
[2230]758 log_it("Reading EXAT files from tape");
[3116]759 res = read_EXAT_files_from_tape(&size, fname, &ctrl_chr,
[128]760 curr_xattr_list_fname,
761 curr_acl_list_fname);
762 }
763 if (ctrl_chr != BLK_START_AN_AFIO_OR_SLICE) {
764 wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr);
765 }
[3191]766 mr_asprintf(tmp, "Verifying fileset #%ld", current_afioball_number);
[128]767 update_progress_form(tmp);
[3191]768 mr_free(tmp);
769
[1645]770 res = verify_an_afioball_from_stream(fname, size);
[128]771 if (res) {
[3191]772 log_to_screen("Afioball %ld differs from live filesystem", current_afioball_number);
[128]773 }
774 retval += res;
775 current_afioball_number++;
776 g_current_progress++;
777 res = read_header_block_from_stream(&size, fname, &ctrl_chr);
778 if (ctrl_chr != BLK_STOP_AN_AFIO_OR_SLICE) {
779 wrong_marker(BLK_STOP_AN_AFIO_OR_SLICE, ctrl_chr);
780 }
[1]781 }
[128]782 log_msg(1, "All done with afioballs");
783 close_progress_form();
784 paranoid_free(fname);
785 paranoid_free(curr_xattr_list_fname);
786 paranoid_free(curr_acl_list_fname);
787 return (retval);
[1]788}
789
790/**
791 * Verify all biggiefiles on the opened CD/tape stream.
792 * @param bkpinfo The backup information structure. Fields used:
793 * - @c bkpinfo->restore_path
794 * - @c bkpinfo->tmpdir
795 *
796 * @return 0 for success (even if there are differences); nonzero for a tape error.
797 */
[1645]798int verify_biggiefiles_from_stream()
[1]799{
800
[128]801 /*@ int ************************************************************ */
802 int retval = 0;
[1]803 int res = 0;
804 int ctrl_chr = 0;
805
[128]806 /*@ long *********************************************************** */
807 long noof_biggiefiles = 0;
[1]808 long current_biggiefile_number = 0;
809
[128]810 /*@ buffers ******************************************************** */
[3191]811 char *orig_fname;
812 char *logical_fname = NULL;
813 char *comment = NULL;
814 char *curr_xattr_list_fname = NULL;
815 char *curr_acl_list_fname = NULL;
[128]816 /*@ pointers ******************************************************* */
[1]817 char *p;
818
[128]819 /*@ long long size ************************************************* */
820 long long size = 0;
[1]821
[128]822 assert(bkpinfo != NULL);
823 malloc_string(orig_fname);
824 malloc_string(curr_xattr_list_fname);
825 malloc_string(curr_acl_list_fname);
[1]826
[948]827 if (g_getfattr) {
828 sprintf(curr_xattr_list_fname, XATTR_BIGGLST_FNAME_RAW_SZ,
[128]829 bkpinfo->tmpdir);
[948]830 }
831 if (g_getfacl) {
832 sprintf(curr_acl_list_fname, ACL_BIGGLST_FNAME_RAW_SZ,
[128]833 bkpinfo->tmpdir);
[948]834 }
[3191]835 mr_asprintf(comment, "Verifying all bigfiles.");
[128]836 log_to_screen(comment);
837 res = read_header_block_from_stream(&size, orig_fname, &ctrl_chr);
838 if (ctrl_chr != BLK_START_BIGGIEFILES) {
839 if (ctrl_chr == BLK_START_EXTENDED_ATTRIBUTES) {
[2230]840 log_it("Grabbing the EXAT biggiefiles");
[3116]841 res = read_EXAT_files_from_tape(&size, orig_fname,
[128]842 &ctrl_chr, curr_xattr_list_fname,
843 curr_acl_list_fname);
844 }
[1]845 }
[128]846 if (ctrl_chr != BLK_START_BIGGIEFILES) {
847 wrong_marker(BLK_START_BIGGIEFILES, ctrl_chr);
[1]848 }
[128]849 noof_biggiefiles = (long) size;
850 log_msg(1, "noof_biggiefiles = %ld", noof_biggiefiles);
[541]851 open_progress_form("Verifying big files", comment,
852 "Please wait. This may take some time.", "",
[128]853 noof_biggiefiles);
[3191]854 mr_free(comment);
855
[128]856 for (res = read_header_block_from_stream(&size, orig_fname, &ctrl_chr);
857 ctrl_chr != BLK_STOP_BIGGIEFILES;
858 res = read_header_block_from_stream(&size, orig_fname, &ctrl_chr))
[1]859 {
[128]860 if (ctrl_chr != BLK_START_A_NORMBIGGIE
861 && ctrl_chr != BLK_START_A_PIHBIGGIE) {
862 wrong_marker(BLK_START_A_NORMBIGGIE, ctrl_chr);
863 }
864 p = strrchr(orig_fname, '/');
865 if (!p) {
866 p = orig_fname;
867 } else {
868 p++;
869 }
[3191]870 mr_asprintf(comment, "Verifying bigfile #%ld (%ld K)", current_biggiefile_number, (long) size >> 10);
[128]871 update_progress_form(comment);
[3191]872 mr_free(comment);
873
[3828]874 if (bkpinfo->restore_path != NULL) {
[3191]875 mr_asprintf(logical_fname, "%s/%s", bkpinfo->restore_path, orig_fname);
876 res = verify_a_biggiefile_from_stream(logical_fname, size);
877 mr_free(logical_fname);
878 retval += res;
879 } else {
880 log_it("Unable to verify bigfile as restore_path is NULL");
881 }
882
[128]883 current_biggiefile_number++;
884 g_current_progress++;
[1]885 }
[128]886 close_progress_form();
887 paranoid_free(orig_fname);
888 paranoid_free(curr_xattr_list_fname);
889 paranoid_free(curr_acl_list_fname);
890 return (retval);
[1]891}
892
893/* @} - end of LLverifyGroup */
894
895
896/**
[1709]897 * Verify the USB device
898 * @param bkpinfo The backup information structure. Fields used:
899 * - @c bkpinfo->media_device
900 * - @c bkpinfo->tmpdir
901 * - @c bkpinfo->verify_data
902 *
903 * @return 0 for success (even if differences are found), nonzero for failure.
904 * @ingroup verifyGroup
905 */
906int verify_usb_image()
907{
908
909 /*@ int ************************************************************ */
910 int retval = 0;
911
912 /*@ buffers ******************************************************** */
913 char *mountpoint = NULL;
914 char *tmp = NULL;
915 char *tmp1 = NULL;
916 char *fname = NULL;
[1711]917 int ret = 0;
[1709]918#ifdef __FreeBSD__
919 char mdd[32];
920 char *mddevice = mdd;
921 int vndev = 2;
922#else
923//skip
924#endif
925
926 assert(bkpinfo != NULL);
927
[3191]928 if (bkpinfo->media_device == NULL) {
929 return(1);
930 }
931
[3185]932 mr_asprintf(fname, "%s1", bkpinfo->media_device);
[1709]933 if (is_this_device_mounted(fname)) {
934 log_msg(1, "USB device mounted. Remounting it at the right place");
[3185]935 mr_asprintf(tmp, "umount %s", fname);
[1709]936 run_program_and_log_output(tmp, FALSE);
937 paranoid_free(tmp);
938 }
939 paranoid_free(fname);
940
941 log_msg(1, "Mounting USB device.");
[3185]942 mr_asprintf(mountpoint, "%s/usb", bkpinfo->tmpdir);
943 mr_asprintf(tmp, "mkdir -p %s", mountpoint);
[1709]944 run_program_and_log_output(tmp, FALSE);
945 paranoid_free(tmp);
946 /* Mindi always create one single parition on the USB dev */
[3185]947 mr_asprintf(tmp, "mount %s1 %s", bkpinfo->media_device, mountpoint);
[1709]948 ret = run_program_and_log_output(tmp, FALSE);
949 paranoid_free(tmp);
950 if (ret) {
951 paranoid_free(mountpoint);
952 return(ret);
953 }
954
955 sync();
[3380]956 log_msg(2, "OK, I've mounted the USB Disk/Key");
[3185]957 mr_asprintf(tmp, "%s/archives/NOT-THE-LAST", mountpoint);
[1709]958 if (!does_file_exist(tmp)) {
959 log_msg
960 (2,
961 "This is the last USB device. I am therefore setting bkpinfo->verify_data to FALSE.");
962 bkpinfo->verify_data = FALSE;
963/*
964 (a) It's an easy way to tell the calling subroutine that we've finished &
965 there are no more device to be verified; (b) It stops the post-backup verifier
966 from running after the per-device verifier has run too.
967*/
968 }
969 paranoid_free(tmp);
970 verify_afioballs_on_CD(mountpoint);
[2230]971 log_it("before verify_all_slices");
[1709]972 verify_all_slices_on_CD(mountpoint);
973
[3185]974 mr_asprintf(tmp1, "umount -d %s", mountpoint);
[1709]975#ifdef __FreeBSD__
976 ret += system(tmp1);
977 ret += kick_vn(mddevice);
978 if (ret)
979#else
980 if (system(tmp1))
981#endif
982 {
[3191]983 log_to_screen("%s failed; unable to unmount USB device\n", tmp1);
[1709]984 retval++;
985 } else {
[3380]986 log_msg(2, "OK, I've unmounted the USB device");
[1709]987 }
[3191]988 mr_free(tmp1);
989 mr_free(mountpoint);
[1709]990 return (retval);
991}
992
993
994/**
[1]995 * Verify the CD indicated by @c g_current_media_number.
996 * @param bkpinfo The backup information structure. Fields used:
997 * - @c bkpinfo->isodir
[20]998 * - @c bkpinfo->prefix
[1]999 * - @c bkpinfo->manual_cd_tray
1000 * - @c bkpinfo->media_device
[2380]1001 * - @c bkpinfo->netfs_remote_dir
[1]1002 * - @c bkpinfo->tmpdir
1003 * - @c bkpinfo->verify_data
1004 *
1005 * @return 0 for success (even if differences are found), nonzero for failure.
1006 * @ingroup verifyGroup
1007 */
[1645]1008int verify_cd_image()
[1]1009{
1010
[128]1011 /*@ int ************************************************************ */
1012 int retval = 0;
[1]1013
[128]1014 /*@ buffers ******************************************************** */
[3191]1015 char *mountpoint = NULL;
1016 char *command = NULL;
1017 char *tmp = NULL;
1018 char *fname = NULL;
[1]1019#ifdef __FreeBSD__
[128]1020 char mdd[32];
[1]1021 char *mddevice = mdd;
[128]1022 int ret = 0;
1023 int vndev = 2;
[1]1024#else
1025//skip
1026#endif
1027
[128]1028 assert(bkpinfo != NULL);
[1]1029
[3191]1030 if (bkpinfo->media_device == NULL) {
1031 return(1);
1032 }
[128]1033
[3191]1034 mr_asprintf(mountpoint, "%s/cdrom", bkpinfo->tmpdir);
1035 if (((bkpinfo->isodir == NULL) && (bkpinfo->netfs_remote_dir == NULL)) || (bkpinfo->prefix == NULL)) {
1036 fatal_error("No iso filename preparation possible");
1037 }
[3207]1038 if (bkpinfo->netfs_remote_dir != NULL) {
[3191]1039 // NETFS
1040 mr_asprintf(fname, "%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->netfs_remote_dir, bkpinfo->prefix, g_current_media_number);
1041 } else {
1042 // ISO
1043 mr_asprintf(fname, "%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->prefix, g_current_media_number);
1044 }
1045
[128]1046 mkdir(mountpoint, 1777);
1047 sync();
1048 if (!does_file_exist(fname)) {
[3191]1049 log_msg(2, "%s not found; assuming you backed up to CD; verifying CD...", fname);
[128]1050 if (bkpinfo->manual_cd_tray) {
[541]1051 popup_and_OK("Please push CD tray closed.");
[128]1052 }
[1645]1053 if (find_and_mount_actual_cd(mountpoint)) {
[541]1054 log_to_screen("failed to mount actual CD");
[3191]1055 mr_free(mountpoint);
1056 mr_free(fname);
[128]1057 return (1);
1058 }
1059 } else {
[3191]1060 log_msg(2, "%s found; verifying ISO...", fname);
[1]1061#ifdef __FreeBSD__
[128]1062 ret = 0;
1063 vndev = 2;
1064 mddevice = make_vn(fname);
1065 if (ret) {
[3191]1066 log_to_screen("make_vn of %s failed; unable to verify ISO\n", fname);
1067 mr_free(mountpoint);
1068 mr_free(fname);
[128]1069 return (1);
1070 }
[3191]1071 mr_asprintf(command, "mount_cd9660 %s %s", mddevice, mountpoint);
[1]1072#else
[3191]1073 mr_asprintf(command, "mount -o loop,ro -t iso9660 %s %s", fname, mountpoint);
[1]1074#endif
[128]1075 if (run_program_and_log_output(command, FALSE)) {
[3191]1076 log_to_screen("%s failed; unable to mount ISO image\n", command);
1077 mr_free(mountpoint);
1078 mr_free(command);
1079 mr_free(fname);
[128]1080 return (1);
1081 }
[3191]1082 mr_free(command);
[1]1083 }
[3380]1084 log_msg(2, "OK, I've mounted the ISO/CD");
[3191]1085 mr_asprintf(tmp, "%s/archives/NOT-THE-LAST", mountpoint);
[128]1086 if (!does_file_exist(tmp)) {
1087 log_msg
1088 (2,
1089 "This is the last CD. I am therefore setting bkpinfo->verify_data to FALSE.");
1090 bkpinfo->verify_data = FALSE;
[1]1091/*
1092 (a) It's an easy way to tell the calling subroutine that we've finished &
1093 there are no more CD's to be verified; (b) It stops the post-backup verifier
1094 from running after the per-CD verifier has run too.
1095*/
[128]1096 }
[3191]1097 mr_free(tmp);
1098
[1645]1099 verify_afioballs_on_CD(mountpoint);
[2230]1100 log_it("before verify_all_slices");
[1645]1101 verify_all_slices_on_CD(mountpoint);
[1]1102
1103#ifdef __FreeBSD__
[128]1104 ret = 0;
[3191]1105 mr_asprintf(command, "umount -d %s", mountpoint);
[128]1106 ret += system(command);
1107 ret += kick_vn(mddevice);
[3191]1108 if (ret) {
[1]1109#else
[3191]1110 mr_asprintf(command, "umount -d %s", mountpoint);
1111 if (system(command)) {
[1]1112#endif
[3191]1113 log_to_screen("%s failed; unable to unmount ISO image\n", command);
1114
[128]1115 retval++;
1116 } else {
[3380]1117 log_msg(2, "OK, I've unmounted the ISO file");
[1]1118 }
[3191]1119 mr_free(mountpoint);
1120 mr_free(command);
1121
[128]1122 if (!does_file_exist(fname)) {
[3191]1123 mr_asprintf(command, "umount -d %s", bkpinfo->media_device);
[128]1124 run_program_and_log_output(command, 2);
[3191]1125 mr_free(command);
1126
1127 if (!bkpinfo->please_dont_eject && eject_device(bkpinfo->media_device)) {
[128]1128 log_msg(2, "Failed to eject CD-ROM drive");
1129 }
1130 }
[3191]1131 mr_free(fname);
[128]1132 return (retval);
[1]1133}
1134
1135/**
1136 * Verify all backups on tape.
1137 * This should be done after the backup process has already closed the tape.
1138 * @param bkpinfo The backup information structure. Passed to various helper functions.
1139 * @return 0 for success (even if thee were differences), nonzero for failure.
1140 * @ingroup verifyGroup
1141 */
[1645]1142int verify_tape_backups()
[1]1143{
1144
[128]1145 /*@ int ************************************************************ */
1146 int retval = 0;
[1]1147
[128]1148 /*@ buffers ******************************************************** */
[3191]1149 char *tmp = NULL;
1150 char *changed_files_fname = NULL;
[1]1151
[128]1152 /*@ long *********************************************************** */
1153 long diffs = 0;
[1]1154
[128]1155 assert(bkpinfo != NULL);
[1]1156
[128]1157 log_msg(3, "verify_tape_backups --- starting");
[541]1158 log_to_screen("Verifying backups");
[1645]1159 openin_tape();
[1]1160/* verify archives themselves */
[1645]1161 retval += verify_afioballs_from_stream();
1162 retval += verify_biggiefiles_from_stream();
[1]1163/* find the final blocks */
[3191]1164 sync();
[128]1165 sleep(2);
[1645]1166 closein_tape();
[1]1167/* close tape; exit */
1168// fclose(g_tape_stream); <-- not needed; is handled by closein_tape()
[3191]1169 mr_asprintf(tmp, "rm -f %s/biggies.changed %s/changed.files 2> /dev/null", bkpinfo->tmpdir, bkpinfo->tmpdir);
[1644]1170 paranoid_system(tmp);
[3191]1171 mr_free(tmp);
1172
1173 mr_asprintf(changed_files_fname, "%s/changed.files", bkpinfo->tmpdir);
1174 mr_asprintf(tmp, "grep -E '^%s:.*$' %s | cut -d'\"' -f2 | sort -u | awk '{print \"/\"$0;};' | tr -s '/' '/' | grep -v \"(total of\" | grep -v \"incheckentry.*xwait\" | grep -vE '^/afio:.*$' | grep -vE '^dev/.*$' > %s", (bkpinfo->use_star) ? "star" : "afio", MONDO_LOGFILE, changed_files_fname);
[128]1175 log_msg(2, "Running command to derive list of changed files");
1176 log_msg(2, tmp);
1177 if (system(tmp)) {
[3191]1178 if (does_file_exist(changed_files_fname) && length_of_file(changed_files_fname) > 2) {
1179 log_to_screen("Warning - unable to check logfile to derive list of changed files");
[128]1180 } else {
[3191]1181 log_to_screen("No differences found. Therefore, no 'changed.files' text file.");
[128]1182 }
1183 }
[3191]1184 mr_free(tmp);
1185
1186 mr_asprintf(tmp, "cat %s/biggies.changed >> %s", bkpinfo->tmpdir, changed_files_fname);
[128]1187 paranoid_system(tmp);
[3191]1188 mr_free(tmp);
[1]1189
[128]1190 diffs = count_lines_in_file(changed_files_fname);
1191 if (diffs > 0) {
[3191]1192 mr_asprintf(tmp, "cp -f %s %s/changed.files", changed_files_fname, MONDO_CACHE);
[128]1193 run_program_and_log_output(tmp, FALSE);
[3191]1194 mr_free(tmp);
1195
1196 log_msg(0, "%ld files differed from live filesystem; type less %s or less %s/changed.files to see", diffs, changed_files_fname, MONDO_CACHE);
[1747]1197 log_to_screen("See "MONDO_CACHE"/changed.files for a list of nonmatching files.");
[1644]1198 log_to_screen("The files probably changed on filesystem, not on backup media.");
[128]1199 }
[3191]1200 mr_free(changed_files_fname);
[128]1201 return (retval);
[1]1202}
1203
1204
1205
Note: See TracBrowser for help on using the repository browser.