Changeset 2366 in MondoRescue
- Timestamp:
- Sep 5, 2009, 1:28:18 AM (15 years ago)
- Location:
- branches
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-filelist.c
r2357 r2366 34 34 /* Reference to global bkpinfo */ 35 35 extern struct s_bkpinfo *bkpinfo; 36 37 38 int mondo_makefilelist(char *logfile, char *include_paths, char *excp, int differential, char *userdef_filelist);39 36 40 37 … … 1276 1273 */ 1277 1274 long g_skeleton_entries = 0; 1275 1276 1277 /** 1278 * Create the filelist for the backup. It will be stored in [scratchdir]/archives/filelist.full. 1279 * @param logfile Unused. 1280 * @param include_paths The paths to back up, or NULL if you're using a user-defined filelist. 1281 * @param excp The paths to NOT back up. 1282 * @param differential The differential level (currently only 0 and 1 are supported). 1283 * @param userdef_filelist The user-defined filelist, or NULL if you're using @p include_paths. 1284 * @return 0, always. 1285 * @bug @p logfile is unused. 1286 * @bug Return value is meaningless. 1287 */ 1288 int mondo_makefilelist(char *logfile, char *include_paths, char *excp, int differential, char *userdef_filelist) 1289 { 1290 char *p, *q; 1291 char *sz_datefile; 1292 char *sz_filelist; 1293 char *exclude_paths = NULL; 1294 char *tmp; 1295 int i; 1296 FILE *fout; 1297 char *command = NULL; 1298 time_t time_of_last_full_backup = 0; 1299 struct stat statbuf; 1300 char *tmp1 = NULL; 1301 char *tmp2 = NULL; 1302 1303 malloc_string(tmp); 1304 malloc_string(g_skeleton_filelist); 1305 mr_asprintf(sz_datefile,MONDO_CACHE"/difflevel.%d" , 0); 1306 if (!include_paths && !userdef_filelist) { 1307 fatal_error("Please supply either include_paths or userdef_filelist"); 1308 } 1309 // make hole for filelist 1310 mr_asprintf(command, "mkdir -p %s/archives", bkpinfo->scratchdir); 1311 paranoid_system(command); 1312 mr_free(command); 1313 1314 mr_asprintf(sz_filelist, "%s/tmpfs/filelist.full", bkpinfo->tmpdir); 1315 make_hole_for_file(sz_filelist); 1316 1317 if (differential == 0) { 1318 // restore last good datefile if it exists 1319 mr_asprintf(command, "cp -f %s.aborted %s", sz_datefile, sz_datefile); 1320 run_program_and_log_output(command, 3); 1321 mr_free(command); 1322 1323 // backup last known good datefile just in case :) 1324 if (does_file_exist(sz_datefile)) { 1325 mr_asprintf(command, "mv -f %s %s.aborted", sz_datefile, sz_datefile); 1326 paranoid_system(command); 1327 mr_free(command); 1328 } 1329 make_hole_for_file(sz_datefile); 1330 write_one_liner_data_file(sz_datefile, 1331 call_program_and_get_last_line_of_output 1332 ("date +%s")); 1333 } else if (lstat(sz_datefile, &statbuf)) { 1334 log_msg(2, "Warning - unable to find date of previous backup. Full backup instead."); 1335 differential = 0; 1336 time_of_last_full_backup = 0; 1337 } else { 1338 time_of_last_full_backup = statbuf.st_mtime; 1339 log_msg(2, "Differential backup. Yay."); 1340 } 1341 paranoid_free(sz_datefile); 1342 1343 // use user-specified filelist (if specified) 1344 if (userdef_filelist) { 1345 log_msg(1, "Using the user-specified filelist - %s - instead of calculating one", userdef_filelist); 1346 mr_asprintf(command, "cp -f %s %s", userdef_filelist, sz_filelist); 1347 if (run_program_and_log_output(command, 3)) { 1348 mr_free(command); 1349 fatal_error("Failed to copy user-specified filelist"); 1350 } 1351 mr_free(command); 1352 } else { 1353 if (include_paths) { 1354 log_msg(2, "include_paths = '%s'", include_paths); 1355 } 1356 log_msg(1, "Calculating filelist"); 1357 mr_asprintf(tmp2, "%s", call_program_and_get_last_line_of_output("mount | grep -Ew 'ntfs|ntfs-3g|fat|vfat|dos' | awk '{print $3}'")); 1358 if (strlen(tmp2) < 1) { 1359 mr_asprintf(tmp1," "); 1360 } else { 1361 log_msg(2, "Found windows FS: %s",tmp2); 1362 mr_asprintf(tmp1, "find %s -name '/win386.swp' -o -name '/hiberfil.sys' -o -name '/pagefile.sys' 2> /dev/null\n",tmp2); 1363 mr_free(tmp2); 1364 mr_asprintf(tmp2, "%s", call_program_and_get_last_line_of_output(tmp1)); 1365 log_msg(2, "Found windows files: %s",tmp2); 1366 } 1367 mr_free(tmp1); 1368 1369 mr_asprintf(exclude_paths, " %s %s %s %s %s . .. " MNT_CDROM " " MNT_FLOPPY " /media /tmp /proc /sys " MINDI_CACHE, MONDO_CACHE, (excp == NULL) ? "" : excp, tmp2, (bkpinfo->tmpdir[0] == '/' && bkpinfo->tmpdir[1] == '/') ? (bkpinfo->tmpdir + 1) : bkpinfo->tmpdir, (bkpinfo->scratchdir[0] == '/' && bkpinfo->scratchdir[1] == '/') ? (bkpinfo->scratchdir + 1) : bkpinfo->scratchdir); 1370 mr_free(tmp2); 1371 1372 log_msg(2, "Excluding paths = '%s'", exclude_paths); 1373 log_msg(2, "Generating skeleton filelist so that we can track our progress"); 1374 sprintf(g_skeleton_filelist, "%s/tmpfs/skeleton.txt", bkpinfo->tmpdir); 1375 make_hole_for_file(g_skeleton_filelist); 1376 log_msg(4, "g_skeleton_entries = %ld", g_skeleton_entries); 1377 log_msg(2, "Opening out filelist to %s", sz_filelist); 1378 if (!(fout = fopen(sz_filelist, "w"))) { 1379 fatal_error("Cannot openout to sz_filelist"); 1380 } 1381 i = 0; 1382 if ((!include_paths) || (strlen(include_paths) == 0)) { 1383 log_msg(1, "Including only '/' in %s", sz_filelist); 1384 open_and_list_dir("/", exclude_paths, fout, 1385 time_of_last_full_backup); 1386 } else { 1387 p = include_paths; 1388 while (*p) { 1389 q = next_entry(p); 1390 log_msg(1, "Including %s in filelist %s", q, sz_filelist); 1391 open_and_list_dir(q, exclude_paths, fout, 1392 time_of_last_full_backup); 1393 p += strlen(q); 1394 paranoid_free(q); 1395 while (*p == ' ') { 1396 p++; 1397 } 1398 } 1399 } 1400 mr_free(exclude_paths); 1401 paranoid_fclose(fout); 1402 } 1403 log_msg(2, "Copying new filelist to scratchdir"); 1404 mr_asprintf(command, "mkdir -p %s/archives", bkpinfo->scratchdir); 1405 paranoid_system(command); 1406 mr_free(command); 1407 1408 mr_asprintf(command, "cp -f %s %s/archives/", sz_filelist, bkpinfo->scratchdir); 1409 paranoid_system(command); 1410 mr_free(command); 1411 1412 mr_asprintf(command, "mv -f %s %s", sz_filelist, bkpinfo->tmpdir); 1413 paranoid_system(command); 1414 mr_free(command); 1415 1416 paranoid_free(sz_filelist); 1417 log_msg(2, "Freeing variables"); 1418 paranoid_free(tmp); 1419 paranoid_free(g_skeleton_filelist); 1420 log_msg(2, "Exiting"); 1421 return (0); 1422 } 1423 1424 1278 1425 1279 1426 /** … … 1529 1676 1530 1677 /** 1531 * Create the filelist for the backup. It will be stored in [scratchdir]/archives/filelist.full.1532 * @param logfile Unused.1533 * @param include_paths The paths to back up, or NULL if you're using a user-defined filelist.1534 * @param excp The paths to NOT back up.1535 * @param differential The differential level (currently only 0 and 1 are supported).1536 * @param userdef_filelist The user-defined filelist, or NULL if you're using @p include_paths.1537 * @return 0, always.1538 * @bug @p logfile is unused.1539 * @bug Return value is meaningless.1540 */1541 int mondo_makefilelist(char *logfile, char *include_paths, char *excp, int differential, char *userdef_filelist)1542 {1543 char *p, *q;1544 char *sz_datefile;1545 char *sz_filelist;1546 char *exclude_paths = NULL;1547 char *tmp;1548 int i;1549 FILE *fout;1550 char *command = NULL;1551 time_t time_of_last_full_backup = 0;1552 struct stat statbuf;1553 char *tmp1 = NULL;1554 char *tmp2 = NULL;1555 1556 malloc_string(tmp);1557 malloc_string(g_skeleton_filelist);1558 mr_asprintf(sz_datefile,MONDO_CACHE"/difflevel.%d" , 0);1559 if (!include_paths && !userdef_filelist) {1560 fatal_error("Please supply either include_paths or userdef_filelist");1561 }1562 // make hole for filelist1563 mr_asprintf(command, "mkdir -p %s/archives", bkpinfo->scratchdir);1564 paranoid_system(command);1565 mr_free(command);1566 1567 mr_asprintf(sz_filelist, "%s/tmpfs/filelist.full", bkpinfo->tmpdir);1568 make_hole_for_file(sz_filelist);1569 1570 if (differential == 0) {1571 // restore last good datefile if it exists1572 mr_asprintf(command, "cp -f %s.aborted %s", sz_datefile, sz_datefile);1573 run_program_and_log_output(command, 3);1574 mr_free(command);1575 1576 // backup last known good datefile just in case :)1577 if (does_file_exist(sz_datefile)) {1578 mr_asprintf(command, "mv -f %s %s.aborted", sz_datefile, sz_datefile);1579 paranoid_system(command);1580 mr_free(command);1581 }1582 make_hole_for_file(sz_datefile);1583 write_one_liner_data_file(sz_datefile,1584 call_program_and_get_last_line_of_output1585 ("date +%s"));1586 } else if (lstat(sz_datefile, &statbuf)) {1587 log_msg(2, "Warning - unable to find date of previous backup. Full backup instead.");1588 differential = 0;1589 time_of_last_full_backup = 0;1590 } else {1591 time_of_last_full_backup = statbuf.st_mtime;1592 log_msg(2, "Differential backup. Yay.");1593 }1594 paranoid_free(sz_datefile);1595 1596 // use user-specified filelist (if specified)1597 if (userdef_filelist) {1598 log_msg(1, "Using the user-specified filelist - %s - instead of calculating one", userdef_filelist);1599 mr_asprintf(command, "cp -f %s %s", userdef_filelist, sz_filelist);1600 if (run_program_and_log_output(command, 3)) {1601 mr_free(command);1602 fatal_error("Failed to copy user-specified filelist");1603 }1604 mr_free(command);1605 } else {1606 if (include_paths) {1607 log_msg(2, "include_paths = '%s'", include_paths);1608 }1609 log_msg(1, "Calculating filelist");1610 mr_asprintf(tmp2, "%s", call_program_and_get_last_line_of_output("mount | grep -Ew 'ntfs|ntfs-3g|fat|vfat|dos' | awk '{print $3}'"));1611 if (strlen(tmp2) < 1) {1612 mr_asprintf(tmp1," ");1613 } else {1614 log_msg(2, "Found windows FS: %s",tmp2);1615 mr_asprintf(tmp1, "find %s -name '/win386.swp' -o -name '/hiberfil.sys' -o -name '/pagefile.sys' 2> /dev/null\n",tmp2);1616 mr_free(tmp2);1617 mr_asprintf(tmp2, "%s", call_program_and_get_last_line_of_output(tmp1));1618 log_msg(2, "Found windows files: %s",tmp2);1619 }1620 mr_free(tmp1);1621 1622 mr_asprintf(exclude_paths, " %s %s %s %s %s . .. " MNT_CDROM " " MNT_FLOPPY " /media /tmp /proc /sys " MINDI_CACHE, MONDO_CACHE, (excp == NULL) ? "" : excp, tmp2, (bkpinfo->tmpdir[0] == '/' && bkpinfo->tmpdir[1] == '/') ? (bkpinfo->tmpdir + 1) : bkpinfo->tmpdir, (bkpinfo->scratchdir[0] == '/' && bkpinfo->scratchdir[1] == '/') ? (bkpinfo->scratchdir + 1) : bkpinfo->scratchdir);1623 mr_free(tmp2);1624 1625 log_msg(2, "Excluding paths = '%s'", exclude_paths);1626 log_msg(2, "Generating skeleton filelist so that we can track our progress");1627 sprintf(g_skeleton_filelist, "%s/tmpfs/skeleton.txt", bkpinfo->tmpdir);1628 make_hole_for_file(g_skeleton_filelist);1629 log_msg(4, "g_skeleton_entries = %ld", g_skeleton_entries);1630 log_msg(2, "Opening out filelist to %s", sz_filelist);1631 if (!(fout = fopen(sz_filelist, "w"))) {1632 fatal_error("Cannot openout to sz_filelist");1633 }1634 i = 0;1635 if ((!include_paths) || (strlen(include_paths) == 0)) {1636 log_msg(1, "Including only '/' in %s", sz_filelist);1637 open_and_list_dir("/", exclude_paths, fout,1638 time_of_last_full_backup);1639 } else {1640 p = include_paths;1641 while (*p) {1642 q = next_entry(p);1643 log_msg(1, "Including %s in filelist %s", q, sz_filelist);1644 open_and_list_dir(q, exclude_paths, fout,1645 time_of_last_full_backup);1646 p += strlen(q);1647 paranoid_free(q);1648 while (*p == ' ') {1649 p++;1650 }1651 }1652 }1653 mr_free(exclude_paths);1654 paranoid_fclose(fout);1655 }1656 log_msg(2, "Copying new filelist to scratchdir");1657 mr_asprintf(command, "mkdir -p %s/archives", bkpinfo->scratchdir);1658 paranoid_system(command);1659 mr_free(command);1660 1661 mr_asprintf(command, "cp -f %s %s/archives/", sz_filelist, bkpinfo->scratchdir);1662 paranoid_system(command);1663 mr_free(command);1664 1665 mr_asprintf(command, "mv -f %s %s", sz_filelist, bkpinfo->tmpdir);1666 paranoid_system(command);1667 mr_free(command);1668 1669 paranoid_free(sz_filelist);1670 log_msg(2, "Freeing variables");1671 paranoid_free(tmp);1672 paranoid_free(g_skeleton_filelist);1673 log_msg(2, "Exiting");1674 return (0);1675 }1676 1677 1678 1679 1680 /**1681 1678 * Locate the string @p string_to_find in the tree rooted at @p startnode. 1682 1679 * @param startnode The node containing the root of the directory tree. -
branches/2.2.9/mondo/src/common/libmondo-filelist.c
r2290 r2366 34 34 /* Reference to global bkpinfo */ 35 35 extern struct s_bkpinfo *bkpinfo; 36 37 38 int mondo_makefilelist(char *logfile, char *tmpdir, char *scratchdir,39 char *include_paths, char *excp, int differential,40 char *userdef_filelist);41 36 42 37 … … 1269 1264 } 1270 1265 } 1266 } 1267 1268 1269 1270 /** 1271 * Create the filelist for the backup. It will be stored in [scratchdir]/archives/filelist.full. 1272 * @param logfile Unused. 1273 * @param tmpdir The tmpdir of the backup. 1274 * @param scratchdir The scratchdir of the backup. 1275 * @param include_paths The paths to back up, or NULL if you're using a user-defined filelist. 1276 * @param excp The paths to NOT back up. 1277 * @param differential The differential level (currently only 0 and 1 are supported). 1278 * @param userdef_filelist The user-defined filelist, or NULL if you're using @p include_paths. 1279 * @return 0, always. 1280 * @bug @p logfile is unused. 1281 * @bug Return value is meaningless. 1282 */ 1283 int mondo_makefilelist(char *logfile, char *tmpdir, char *scratchdir, 1284 char *include_paths, char *excp, int differential, 1285 char *userdef_filelist) 1286 { 1287 char *p, *q; 1288 char *sz_datefile; 1289 char *sz_filelist, *exclude_paths, *tmp; 1290 int i; 1291 FILE *fout; 1292 char *command; 1293 time_t time_of_last_full_backup = 0; 1294 struct stat statbuf; 1295 char *tmp1 = NULL; 1296 char *tmp2 = NULL; 1297 1298 malloc_string(command); 1299 malloc_string(tmp); 1300 malloc_string(g_skeleton_filelist); 1301 if (!(exclude_paths = malloc(8*MAX_STR_LEN))) { 1302 fatal_error("Cannot malloc exclude_paths"); 1303 } 1304 mr_asprintf(&sz_datefile,MONDO_CACHE"/difflevel.%d" , 0); 1305 if (!include_paths && !userdef_filelist) { 1306 fatal_error 1307 ("Please supply either include_paths or userdef_filelist"); 1308 } 1309 // make hole for filelist 1310 sprintf(command, "mkdir -p %s/archives", scratchdir); 1311 paranoid_system(command); 1312 mr_asprintf(&sz_filelist, "%s/tmpfs/filelist.full", tmpdir); 1313 make_hole_for_file(sz_filelist); 1314 1315 if (differential == 0) { 1316 // restore last good datefile if it exists 1317 sprintf(command, "cp -f %s.aborted %s", sz_datefile, sz_datefile); 1318 run_program_and_log_output(command, 3); 1319 // backup last known good datefile just in case :) 1320 if (does_file_exist(sz_datefile)) { 1321 sprintf(command, "mv -f %s %s.aborted", sz_datefile, 1322 sz_datefile); 1323 paranoid_system(command); 1324 } 1325 make_hole_for_file(sz_datefile); 1326 write_one_liner_data_file(sz_datefile, 1327 call_program_and_get_last_line_of_output 1328 ("date +%s")); 1329 } else if (lstat(sz_datefile, &statbuf)) { 1330 log_msg(2, 1331 "Warning - unable to find date of previous backup. Full backup instead."); 1332 differential = 0; 1333 time_of_last_full_backup = 0; 1334 } else { 1335 time_of_last_full_backup = statbuf.st_mtime; 1336 log_msg(2, "Differential backup. Yay."); 1337 } 1338 paranoid_free(sz_datefile); 1339 1340 // use user-specified filelist (if specified) 1341 if (userdef_filelist) { 1342 log_msg(1, 1343 "Using the user-specified filelist - %s - instead of calculating one", 1344 userdef_filelist); 1345 sprintf(command, "cp -f %s %s", userdef_filelist, sz_filelist); 1346 if (run_program_and_log_output(command, 3)) { 1347 fatal_error("Failed to copy user-specified filelist"); 1348 } 1349 } else { 1350 log_msg(2, "include_paths = '%s'", include_paths); 1351 log_msg(1, "Calculating filelist"); 1352 mr_asprintf(&tmp2, "%s", call_program_and_get_last_line_of_output("mount | grep -Ew 'ntfs|ntfs-3g|fat|vfat|dos' | awk '{print $3}'")); 1353 if (strlen(tmp2) < 1) { 1354 mr_asprintf(&tmp1," "); 1355 } else { 1356 log_msg(2, "Found windows FS: %s",tmp2); 1357 mr_asprintf(&tmp1, "find %s -name '/win386.swp' -o -name '/hiberfil.sys' -o -name '/pagefile.sys' 2> /dev/null\n",tmp2); 1358 paranoid_free(tmp2); 1359 mr_asprintf(&tmp2, "%s", call_program_and_get_last_line_of_output(tmp1)); 1360 log_msg(2, "Found windows files: %s",tmp2); 1361 } 1362 paranoid_free(tmp1); 1363 1364 snprintf(exclude_paths, (size_t)8*MAX_STR_LEN," %s %s %s %s %s . .. \ 1365 " MNT_CDROM " " MNT_FLOPPY " /media /tmp \ 1366 /proc /sys " MINDI_CACHE, MONDO_CACHE, excp, tmp2, (tmpdir[0] == '/' && tmpdir[1] == '/') ? (tmpdir + 1) : tmpdir, (scratchdir[0] == '/' && scratchdir[1] == '/') ? (scratchdir + 1) : scratchdir); 1367 paranoid_free(tmp2); 1368 1369 log_msg(2, "Excluding paths = '%s'", exclude_paths); 1370 log_msg(2, 1371 "Generating skeleton filelist so that we can track our progress"); 1372 sprintf(g_skeleton_filelist, "%s/tmpfs/skeleton.txt", tmpdir); 1373 make_hole_for_file(g_skeleton_filelist); 1374 log_msg(4, "g_skeleton_entries = %ld", g_skeleton_entries); 1375 log_msg(2, "Opening out filelist to %s", sz_filelist); 1376 if (!(fout = fopen(sz_filelist, "w"))) { 1377 fatal_error("Cannot openout to sz_filelist"); 1378 } 1379 i = 0; 1380 if (strlen(include_paths) == 0) { 1381 log_msg(1, "Including only '/' in %s", sz_filelist); 1382 open_and_list_dir("/", exclude_paths, fout, 1383 time_of_last_full_backup); 1384 } else { 1385 p = include_paths; 1386 while (*p) { 1387 q = next_entry(p); 1388 log_msg(1, "Including %s in filelist %s", q, sz_filelist); 1389 open_and_list_dir(q, exclude_paths, fout, 1390 time_of_last_full_backup); 1391 p += strlen(q); 1392 paranoid_free(q); 1393 while (*p == ' ') { 1394 p++; 1395 } 1396 } 1397 } 1398 paranoid_fclose(fout); 1399 } 1400 log_msg(2, "Copying new filelist to scratchdir"); 1401 sprintf(command, "mkdir -p %s/archives", scratchdir); 1402 paranoid_system(command); 1403 sprintf(command, "cp -f %s %s/archives/", sz_filelist, scratchdir); 1404 paranoid_system(command); 1405 sprintf(command, "mv -f %s %s", sz_filelist, tmpdir); 1406 paranoid_system(command); 1407 paranoid_free(sz_filelist); 1408 log_msg(2, "Freeing variables"); 1409 paranoid_free(command); 1410 paranoid_free(exclude_paths); 1411 paranoid_free(tmp); 1412 paranoid_free(g_skeleton_filelist); 1413 log_msg(2, "Exiting"); 1414 return (0); 1271 1415 } 1272 1416 … … 1562 1706 1563 1707 /** 1564 * Create the filelist for the backup. It will be stored in [scratchdir]/archives/filelist.full.1565 * @param logfile Unused.1566 * @param tmpdir The tmpdir of the backup.1567 * @param scratchdir The scratchdir of the backup.1568 * @param include_paths The paths to back up, or NULL if you're using a user-defined filelist.1569 * @param excp The paths to NOT back up.1570 * @param differential The differential level (currently only 0 and 1 are supported).1571 * @param userdef_filelist The user-defined filelist, or NULL if you're using @p include_paths.1572 * @return 0, always.1573 * @bug @p logfile is unused.1574 * @bug Return value is meaningless.1575 */1576 int mondo_makefilelist(char *logfile, char *tmpdir, char *scratchdir,1577 char *include_paths, char *excp, int differential,1578 char *userdef_filelist)1579 {1580 char *p, *q;1581 char *sz_datefile;1582 char *sz_filelist, *exclude_paths, *tmp;1583 int i;1584 FILE *fout;1585 char *command;1586 time_t time_of_last_full_backup = 0;1587 struct stat statbuf;1588 char *tmp1 = NULL;1589 char *tmp2 = NULL;1590 1591 malloc_string(command);1592 malloc_string(tmp);1593 malloc_string(g_skeleton_filelist);1594 if (!(exclude_paths = malloc(8*MAX_STR_LEN))) {1595 fatal_error("Cannot malloc exclude_paths");1596 }1597 mr_asprintf(&sz_datefile,MONDO_CACHE"/difflevel.%d" , 0);1598 if (!include_paths && !userdef_filelist) {1599 fatal_error1600 ("Please supply either include_paths or userdef_filelist");1601 }1602 // make hole for filelist1603 sprintf(command, "mkdir -p %s/archives", scratchdir);1604 paranoid_system(command);1605 mr_asprintf(&sz_filelist, "%s/tmpfs/filelist.full", tmpdir);1606 make_hole_for_file(sz_filelist);1607 1608 if (differential == 0) {1609 // restore last good datefile if it exists1610 sprintf(command, "cp -f %s.aborted %s", sz_datefile, sz_datefile);1611 run_program_and_log_output(command, 3);1612 // backup last known good datefile just in case :)1613 if (does_file_exist(sz_datefile)) {1614 sprintf(command, "mv -f %s %s.aborted", sz_datefile,1615 sz_datefile);1616 paranoid_system(command);1617 }1618 make_hole_for_file(sz_datefile);1619 write_one_liner_data_file(sz_datefile,1620 call_program_and_get_last_line_of_output1621 ("date +%s"));1622 } else if (lstat(sz_datefile, &statbuf)) {1623 log_msg(2,1624 "Warning - unable to find date of previous backup. Full backup instead.");1625 differential = 0;1626 time_of_last_full_backup = 0;1627 } else {1628 time_of_last_full_backup = statbuf.st_mtime;1629 log_msg(2, "Differential backup. Yay.");1630 }1631 paranoid_free(sz_datefile);1632 1633 // use user-specified filelist (if specified)1634 if (userdef_filelist) {1635 log_msg(1,1636 "Using the user-specified filelist - %s - instead of calculating one",1637 userdef_filelist);1638 sprintf(command, "cp -f %s %s", userdef_filelist, sz_filelist);1639 if (run_program_and_log_output(command, 3)) {1640 fatal_error("Failed to copy user-specified filelist");1641 }1642 } else {1643 log_msg(2, "include_paths = '%s'", include_paths);1644 log_msg(1, "Calculating filelist");1645 mr_asprintf(&tmp2, "%s", call_program_and_get_last_line_of_output("mount | grep -Ew 'ntfs|ntfs-3g|fat|vfat|dos' | awk '{print $3}'"));1646 if (strlen(tmp2) < 1) {1647 mr_asprintf(&tmp1," ");1648 } else {1649 log_msg(2, "Found windows FS: %s",tmp2);1650 mr_asprintf(&tmp1, "find %s -name '/win386.swp' -o -name '/hiberfil.sys' -o -name '/pagefile.sys' 2> /dev/null\n",tmp2);1651 paranoid_free(tmp2);1652 mr_asprintf(&tmp2, "%s", call_program_and_get_last_line_of_output(tmp1));1653 log_msg(2, "Found windows files: %s",tmp2);1654 }1655 paranoid_free(tmp1);1656 1657 snprintf(exclude_paths, (size_t)8*MAX_STR_LEN," %s %s %s %s %s . .. \1658 " MNT_CDROM " " MNT_FLOPPY " /media /tmp \1659 /proc /sys " MINDI_CACHE, MONDO_CACHE, excp, tmp2, (tmpdir[0] == '/' && tmpdir[1] == '/') ? (tmpdir + 1) : tmpdir, (scratchdir[0] == '/' && scratchdir[1] == '/') ? (scratchdir + 1) : scratchdir);1660 paranoid_free(tmp2);1661 1662 log_msg(2, "Excluding paths = '%s'", exclude_paths);1663 log_msg(2,1664 "Generating skeleton filelist so that we can track our progress");1665 sprintf(g_skeleton_filelist, "%s/tmpfs/skeleton.txt", tmpdir);1666 make_hole_for_file(g_skeleton_filelist);1667 log_msg(4, "g_skeleton_entries = %ld", g_skeleton_entries);1668 log_msg(2, "Opening out filelist to %s", sz_filelist);1669 if (!(fout = fopen(sz_filelist, "w"))) {1670 fatal_error("Cannot openout to sz_filelist");1671 }1672 i = 0;1673 if (strlen(include_paths) == 0) {1674 log_msg(1, "Including only '/' in %s", sz_filelist);1675 open_and_list_dir("/", exclude_paths, fout,1676 time_of_last_full_backup);1677 } else {1678 p = include_paths;1679 while (*p) {1680 q = next_entry(p);1681 log_msg(1, "Including %s in filelist %s", q, sz_filelist);1682 open_and_list_dir(q, exclude_paths, fout,1683 time_of_last_full_backup);1684 p += strlen(q);1685 paranoid_free(q);1686 while (*p == ' ') {1687 p++;1688 }1689 }1690 }1691 paranoid_fclose(fout);1692 }1693 log_msg(2, "Copying new filelist to scratchdir");1694 sprintf(command, "mkdir -p %s/archives", scratchdir);1695 paranoid_system(command);1696 sprintf(command, "cp -f %s %s/archives/", sz_filelist, scratchdir);1697 paranoid_system(command);1698 sprintf(command, "mv -f %s %s", sz_filelist, tmpdir);1699 paranoid_system(command);1700 paranoid_free(sz_filelist);1701 log_msg(2, "Freeing variables");1702 paranoid_free(command);1703 paranoid_free(exclude_paths);1704 paranoid_free(tmp);1705 paranoid_free(g_skeleton_filelist);1706 log_msg(2, "Exiting");1707 return (0);1708 }1709 1710 1711 1712 1713 /**1714 1708 * Locate the string @p string_to_find in the tree rooted at @p startnode. 1715 1709 * @param startnode The node containing the root of the directory tree.
Note:
See TracChangeset
for help on using the changeset viewer.