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