[1] | 1 | /***************************************************************************
|
---|
[2211] | 2 | $Id: mondoarchive.c 3185 2013-09-20 12:29:57Z bruno $
|
---|
| 3 | * The main file for mondoarchive.
|
---|
| 4 | */
|
---|
[1] | 5 |
|
---|
| 6 | /************************* #include statements *************************/
|
---|
| 7 | #include <pthread.h>
|
---|
| 8 | #include <stdio.h>
|
---|
| 9 | #include <stdlib.h>
|
---|
[1930] | 10 | #include "my-stuff.h"
|
---|
[2211] | 11 | #include "mr_mem.h"
|
---|
[1] | 12 | #include "../common/mondostructures.h"
|
---|
| 13 | #include "../common/libmondo.h"
|
---|
[1917] | 14 | #include "../common/libmondo-cli-EXT.h"
|
---|
[1383] | 15 | #include "../common/libmondo-tools-EXT.h"
|
---|
[1315] | 16 | #include "mondoarchive.h"
|
---|
[1] | 17 |
|
---|
| 18 | // for CVS
|
---|
[128] | 19 | //static char cvsid[] = "$Id: mondoarchive.c 3185 2013-09-20 12:29:57Z bruno $";
|
---|
[1] | 20 |
|
---|
| 21 | /************************* external variables *************************/
|
---|
| 22 | extern void set_signals(int);
|
---|
| 23 | extern int g_current_media_number;
|
---|
| 24 | extern int g_currentY;
|
---|
| 25 | extern bool g_text_mode;
|
---|
| 26 | extern char *g_boot_mountpt;
|
---|
[1736] | 27 | extern bool g_remount_floppy_at_end;
|
---|
[1] | 28 | extern char *g_cdrw_drive_is_here;
|
---|
[128] | 29 | static char *g_cdrom_drive_is_here = NULL;
|
---|
| 30 | static char *g_dvd_drive_is_here = NULL;
|
---|
[1] | 31 | extern double g_kernel_version;
|
---|
| 32 |
|
---|
| 33 | /***************** global vars, used only by main.c ******************/
|
---|
| 34 | long diffs;
|
---|
| 35 |
|
---|
| 36 | extern t_bkptype g_backup_media_type;
|
---|
| 37 | extern int g_loglevel;
|
---|
| 38 |
|
---|
[1917] | 39 | /**
|
---|
| 40 | * Whether we're restoring from ISOs. Obviously not, since this is the
|
---|
| 41 | * backup program.
|
---|
| 42 | * @note You @b MUST declare this variable somewhere in your program if
|
---|
| 43 | * you use libmondo. Otherwise the link will fail.
|
---|
| 44 | * @ingroup globalGroup
|
---|
| 45 | */
|
---|
| 46 | bool g_ISO_restore_mode = FALSE;
|
---|
| 47 |
|
---|
[3141] | 48 | /* Whether we should fail immediately at first error */
|
---|
| 49 | bool g_fail_immediately = FALSE;
|
---|
| 50 |
|
---|
[1917] | 51 | /* Do we use extended attributes and acl ?
|
---|
| 52 | * * By default no, use --acl & --attr options to force their usage */
|
---|
| 53 | char *g_getfacl = NULL;
|
---|
| 54 | char *g_getfattr = NULL;
|
---|
| 55 |
|
---|
[1645] | 56 | /* Reference to global bkpinfo */
|
---|
| 57 | struct s_bkpinfo *bkpinfo;
|
---|
| 58 |
|
---|
[2211] | 59 | /* No cleanup for the moment */
|
---|
| 60 | void (*mr_cleanup)(void) = NULL;
|
---|
| 61 |
|
---|
[1967] | 62 | /* To be coded */
|
---|
| 63 | void free_MR_global_filenames(void) {
|
---|
| 64 | }
|
---|
| 65 |
|
---|
[1] | 66 | /****************** subroutines used only by main.c ******************/
|
---|
| 67 |
|
---|
| 68 |
|
---|
| 69 | /**
|
---|
| 70 | * Print a "don't panic" message to the log and a message about the logfile to the screen.
|
---|
| 71 | */
|
---|
[1236] | 72 | void welcome_to_mondoarchive(void)
|
---|
[1] | 73 | {
|
---|
[1375] | 74 | char *tmp = NULL;
|
---|
| 75 |
|
---|
[128] | 76 | log_msg(0, "Mondo Archive v%s --- http://www.mondorescue.org",
|
---|
[251] | 77 | PACKAGE_VERSION);
|
---|
[1375] | 78 | log_msg(0, "running %s binaries", get_architecture());
|
---|
| 79 | tmp = get_uname_m();
|
---|
| 80 | log_msg(0, "running on %s architecture", tmp);
|
---|
[2241] | 81 | mr_free(tmp);
|
---|
[128] | 82 | log_msg(0,
|
---|
| 83 | "-----------------------------------------------------------");
|
---|
| 84 | log_msg(0,
|
---|
| 85 | "NB: Mondo logs almost everything, so don't panic if you see");
|
---|
| 86 | log_msg(0,
|
---|
| 87 | "some error messages. Please read them carefully before you");
|
---|
| 88 | log_msg(0,
|
---|
| 89 | "decide to break out in a cold sweat. Despite (or perhaps");
|
---|
| 90 | log_msg(0,
|
---|
| 91 | "because of) the wealth of messages. some users are inclined");
|
---|
| 92 | log_msg(0,
|
---|
| 93 | "to stop reading this log. If Mondo stopped for some reason,");
|
---|
| 94 | log_msg(0,
|
---|
| 95 | "chances are it's detailed here. More than likely there's a");
|
---|
| 96 | log_msg(0,
|
---|
| 97 | "message at the very end of this log that will tell you what");
|
---|
| 98 | log_msg(0,
|
---|
| 99 | "is wrong. Please read it! -Devteam");
|
---|
| 100 | log_msg(0,
|
---|
| 101 | "-----------------------------------------------------------");
|
---|
[1] | 102 |
|
---|
[128] | 103 | log_msg(0, "Zero...");
|
---|
| 104 | log_msg(1, "One...");
|
---|
| 105 | log_msg(2, "Two...");
|
---|
| 106 | log_msg(3, "Three...");
|
---|
| 107 | log_msg(4, "Four...");
|
---|
| 108 | log_msg(5, "Five...");
|
---|
| 109 | log_msg(6, "Six...");
|
---|
| 110 | log_msg(7, "Seven...");
|
---|
| 111 | log_msg(8, "Eight...");
|
---|
| 112 | printf("See %s for details of backup run.\n", MONDO_LOGFILE);
|
---|
[1] | 113 | }
|
---|
| 114 |
|
---|
| 115 |
|
---|
| 116 | extern char *g_magicdev_command;
|
---|
| 117 |
|
---|
| 118 | /**
|
---|
| 119 | * Do whatever is necessary to insure a successful backup on the Linux distribution
|
---|
| 120 | * of the day.
|
---|
| 121 | */
|
---|
[1236] | 122 | void distro_specific_kludges_at_start_of_mondoarchive(void)
|
---|
[1] | 123 | {
|
---|
[128] | 124 | log_msg(2, "Unmounting old ramdisks if necessary");
|
---|
| 125 | stop_magicdev_if_necessary(); // for RH+Gnome users
|
---|
[2030] | 126 | /*
|
---|
[128] | 127 | run_program_and_log_output
|
---|
| 128 | ("umount `mount | grep shm | grep mondo | cut -d' ' -f3`", 2);
|
---|
[2030] | 129 | */
|
---|
[128] | 130 | unmount_supermounts_if_necessary(); // for Mandrake users whose CD-ROMs are supermounted
|
---|
| 131 | // stop_autofs_if_necessary(); // for Xandros users
|
---|
| 132 | mount_boot_if_necessary(); // for Gentoo users with non-mounted /boot partitions
|
---|
| 133 | clean_up_KDE_desktop_if_necessary(); // delete various misc ~/.* files that get in the way
|
---|
[1] | 134 | }
|
---|
| 135 |
|
---|
| 136 |
|
---|
| 137 |
|
---|
| 138 | /**
|
---|
| 139 | * Undo whatever was done by distro_specific_kludges_at_start_of_mondoarchive().
|
---|
| 140 | */
|
---|
[1236] | 141 | void distro_specific_kludges_at_end_of_mondoarchive(void)
|
---|
[1] | 142 | {
|
---|
[128] | 143 | log_msg(2, "Restarting magicdev if necessary");
|
---|
| 144 | sync();
|
---|
| 145 | restart_magicdev_if_necessary(); // for RH+Gnome users
|
---|
[1] | 146 |
|
---|
[128] | 147 | log_msg(2, "Restarting autofs if necessary");
|
---|
| 148 | sync();
|
---|
| 149 | // restart_autofs_if_necessary(); // for Xandros users
|
---|
[1] | 150 |
|
---|
[128] | 151 | log_msg(2, "Restarting supermounts if necessary");
|
---|
| 152 | sync();
|
---|
| 153 | remount_supermounts_if_necessary(); // for Mandrake users
|
---|
[1] | 154 |
|
---|
[128] | 155 | log_msg(2, "Unmounting /boot if necessary");
|
---|
| 156 | sync();
|
---|
| 157 | unmount_boot_if_necessary(); // for Gentoo users
|
---|
[1] | 158 |
|
---|
| 159 | // log_msg( 2, "Cleaning up KDE desktop");
|
---|
| 160 | // clean_up_KDE_desktop_if_necessary();
|
---|
| 161 | }
|
---|
| 162 |
|
---|
| 163 |
|
---|
| 164 | /**
|
---|
| 165 | * Backup/verify the user's data.
|
---|
| 166 | * What did you think it did, anyway? :-)
|
---|
| 167 | */
|
---|
[128] | 168 | int main(int argc, char *argv[])
|
---|
[1] | 169 | {
|
---|
[2241] | 170 | char *tmp = NULL;
|
---|
[2113] | 171 | char *tmp1 = NULL;
|
---|
[128] | 172 | int res, retval;
|
---|
[2211] | 173 | char *say_at_end = NULL;
|
---|
[2982] | 174 | FILE *fin = NULL;
|
---|
[1] | 175 |
|
---|
| 176 | /* Make sure I'm root; abort if not */
|
---|
[128] | 177 | if (getuid() != 0) {
|
---|
[541] | 178 | fprintf(stderr, "Please run as root.\r\n");
|
---|
[128] | 179 | exit(127);
|
---|
| 180 | }
|
---|
[1] | 181 |
|
---|
| 182 | /* If -V, -v or --version then echo version no. and quit */
|
---|
[128] | 183 | if (argc == 2
|
---|
| 184 | && (!strcmp(argv[argc - 1], "-v") || !strcmp(argv[argc - 1], "-V")
|
---|
| 185 | || !strcmp(argv[argc - 1], "--version"))) {
|
---|
[541] | 186 | printf("mondoarchive v%s\nSee man page for help\n", PACKAGE_VERSION);
|
---|
[128] | 187 | exit(0);
|
---|
| 188 | }
|
---|
[1] | 189 |
|
---|
| 190 | /* Initialize variables */
|
---|
| 191 |
|
---|
[1652] | 192 | printf("Initializing...\n");
|
---|
[2687] | 193 | if (!(bkpinfo = (struct s_bkpinfo *)malloc(sizeof(struct s_bkpinfo)))) {
|
---|
[1652] | 194 | fatal_error("Cannot malloc bkpinfo");
|
---|
| 195 | }
|
---|
| 196 | reset_bkpinfo();
|
---|
[1] | 197 |
|
---|
[128] | 198 | res = 0;
|
---|
| 199 | retval = 0;
|
---|
| 200 | diffs = 0;
|
---|
[1652] | 201 | malloc_libmondo_global_strings();
|
---|
[1] | 202 |
|
---|
[810] | 203 | /* initialize log file with time stamp */
|
---|
| 204 | unlink(MONDO_LOGFILE);
|
---|
[813] | 205 | log_msg(0, "Time started: %s", mr_date());
|
---|
[1] | 206 |
|
---|
[807] | 207 | /* make sure PATH environmental variable allows access to mkfs, fdisk, etc. */
|
---|
[3185] | 208 | mr_asprintf(tmp1,"%s:/sbin:/usr/sbin:/usr/local/sbin",getenv("PATH"));
|
---|
[2113] | 209 | setenv("PATH", tmp1, 1);
|
---|
| 210 | paranoid_free(tmp1);
|
---|
[1] | 211 |
|
---|
[807] | 212 | /* Add the ARCH environment variable for ia64 purposes */
|
---|
[3185] | 213 | mr_asprintf(tmp1,"%s",get_architecture());
|
---|
[2113] | 214 | setenv("ARCH", tmp1, 1);
|
---|
| 215 | paranoid_free(tmp1);
|
---|
[1] | 216 |
|
---|
[424] | 217 | /* Add MONDO_SHARE environment variable for mindi */
|
---|
| 218 | setenv_mondo_share();
|
---|
[258] | 219 |
|
---|
[807] | 220 | /* Configure the bkpinfo structure, global file paths, etc. */
|
---|
[128] | 221 | g_main_pid = getpid();
|
---|
| 222 | log_msg(9, "This");
|
---|
[1] | 223 |
|
---|
[128] | 224 | set_signals(TRUE); // catch SIGTERM, etc.
|
---|
| 225 | run_program_and_log_output("dmesg -n1", TRUE);
|
---|
[1] | 226 |
|
---|
[128] | 227 | log_msg(9, "Next");
|
---|
[1747] | 228 | make_hole_for_dir(MONDO_CACHE);
|
---|
| 229 |
|
---|
[128] | 230 | welcome_to_mondoarchive();
|
---|
| 231 | distro_specific_kludges_at_start_of_mondoarchive();
|
---|
| 232 | g_kernel_version = get_kernel_version();
|
---|
[1] | 233 |
|
---|
[128] | 234 | if (argc == 4 && !strcmp(argv[1], "getfattr")) {
|
---|
| 235 | g_loglevel = 10;
|
---|
| 236 | g_text_mode = TRUE;
|
---|
| 237 | setup_newt_stuff();
|
---|
| 238 | if (!strstr(argv[2], "filelist")) {
|
---|
[541] | 239 | printf("Sorry - filelist goes first\n");
|
---|
[128] | 240 | finish(1);
|
---|
| 241 | } else {
|
---|
| 242 | finish(get_fattr_list(argv[2], argv[3]));
|
---|
| 243 | }
|
---|
| 244 | finish(0);
|
---|
[1] | 245 | }
|
---|
[128] | 246 | if (argc == 4 && !strcmp(argv[1], "setfattr")) {
|
---|
| 247 | g_loglevel = 10;
|
---|
| 248 | g_text_mode = TRUE;
|
---|
| 249 | setup_newt_stuff();
|
---|
| 250 | finish(set_fattr_list(argv[2], argv[3]));
|
---|
[1] | 251 | }
|
---|
[128] | 252 |
|
---|
| 253 | if (argc == 3 && !strcmp(argv[1], "wildcards")) {
|
---|
| 254 | g_loglevel = 10;
|
---|
| 255 | g_text_mode = TRUE;
|
---|
| 256 | setup_newt_stuff();
|
---|
[2241] | 257 | malloc_string(tmp);
|
---|
[128] | 258 | turn_wildcard_chars_into_literal_chars(tmp, argv[2]);
|
---|
| 259 | printf("in=%s; out=%s\n", argv[2], tmp);
|
---|
[2241] | 260 | paranoid_free(tmp);
|
---|
[128] | 261 | finish(1);
|
---|
[1] | 262 | }
|
---|
[128] | 263 |
|
---|
| 264 | if (argc == 4 && !strcmp(argv[1], "getfacl")) {
|
---|
| 265 | g_loglevel = 10;
|
---|
| 266 | g_text_mode = TRUE;
|
---|
| 267 | setup_newt_stuff();
|
---|
| 268 | if (!strstr(argv[2], "filelist")) {
|
---|
[541] | 269 | printf("Sorry - filelist goes first\n");
|
---|
[128] | 270 | finish(1);
|
---|
| 271 | } else {
|
---|
| 272 | finish(get_acl_list(argv[2], argv[3]));
|
---|
| 273 | }
|
---|
| 274 | finish(0);
|
---|
| 275 | }
|
---|
| 276 | if (argc == 4 && !strcmp(argv[1], "setfacl")) {
|
---|
| 277 | g_loglevel = 10;
|
---|
| 278 | g_text_mode = TRUE;
|
---|
| 279 | setup_newt_stuff();
|
---|
| 280 | finish(set_acl_list(argv[2], argv[3]));
|
---|
| 281 | }
|
---|
[2982] | 282 | if (argc >= 2 && !strcmp(argv[1], "mkraidtab")) {
|
---|
| 283 | g_loglevel = 10;
|
---|
| 284 | g_text_mode = TRUE;
|
---|
| 285 | setup_newt_stuff();
|
---|
| 286 | #undef MDSTAT_FILE
|
---|
| 287 | #define MDSTAT_FILE "/tmp/mdstat"
|
---|
| 288 | if (!(fin = fopen(MDSTAT_FILE, "r"))) {
|
---|
| 289 | log_msg(1, "Could not open %s.\n", MDSTAT_FILE);
|
---|
| 290 | finish(1);
|
---|
| 291 | }
|
---|
[1] | 292 |
|
---|
[2982] | 293 | create_raidtab_from_mdstat(MDSTAT_FILE,"/tmp/raidtab");
|
---|
| 294 | finish(0);
|
---|
| 295 | }
|
---|
| 296 |
|
---|
[128] | 297 | if (argc > 2 && !strcmp(argv[1], "find-cd")) {
|
---|
| 298 | g_loglevel = 10;
|
---|
| 299 | g_text_mode = TRUE;
|
---|
| 300 | setup_newt_stuff();
|
---|
[2241] | 301 | malloc_string(tmp);
|
---|
[128] | 302 | if (find_cdrw_device(tmp)) {
|
---|
[541] | 303 | printf("Failed to find CDR-RW drive\n");
|
---|
[128] | 304 | } else {
|
---|
[541] | 305 | printf("CD-RW is at %s\n", tmp);
|
---|
[128] | 306 | }
|
---|
| 307 | tmp[0] = '\0';
|
---|
| 308 | if (find_cdrom_device(tmp, atoi(argv[2]))) {
|
---|
[541] | 309 | printf("Failed to find CD-ROM drive\n");
|
---|
[128] | 310 | } else {
|
---|
[541] | 311 | printf("CD-ROM is at %s\n", tmp);
|
---|
[128] | 312 | }
|
---|
[2241] | 313 | paranoid_free(tmp);
|
---|
[128] | 314 | finish(0);
|
---|
| 315 | }
|
---|
[1] | 316 |
|
---|
[128] | 317 | if (argc > 2 && !strcmp(argv[1], "find-dvd")) {
|
---|
| 318 | g_loglevel = 10;
|
---|
| 319 | g_text_mode = TRUE;
|
---|
| 320 | setup_newt_stuff();
|
---|
[2241] | 321 | malloc_string(tmp);
|
---|
[128] | 322 | if (find_dvd_device(tmp, atoi(argv[2]))) {
|
---|
[541] | 323 | printf("Failed to find DVD drive\n");
|
---|
[128] | 324 | } else {
|
---|
[541] | 325 | printf("DVD is at %s\n", tmp);
|
---|
[128] | 326 | }
|
---|
[2241] | 327 | paranoid_free(tmp);
|
---|
[128] | 328 | finish(0);
|
---|
| 329 | }
|
---|
[1] | 330 |
|
---|
[128] | 331 | if (argc > 2 && !strcmp(argv[1], "disksize")) {
|
---|
| 332 | printf("%s --> %ld\n", argv[2], get_phys_size_of_drive(argv[2]));
|
---|
| 333 | finish(0);
|
---|
| 334 | }
|
---|
| 335 | if (argc > 2 && !strcmp(argv[1], "test-dev")) {
|
---|
| 336 | if (is_dev_an_NTFS_dev(argv[2])) {
|
---|
[541] | 337 | printf("%s is indeed an NTFS dev\n", argv[2]);
|
---|
[128] | 338 | } else {
|
---|
[541] | 339 | printf("%s is _not_ an NTFS dev\n", argv[2]);
|
---|
[128] | 340 | }
|
---|
| 341 | finish(0);
|
---|
| 342 | }
|
---|
| 343 |
|
---|
[1645] | 344 | if (pre_param_configuration()) {
|
---|
[128] | 345 | fatal_error
|
---|
| 346 | ("Pre-param initialization phase failed. Please review the error messages above, make the specified changes, then try again. Exiting...");
|
---|
| 347 | }
|
---|
| 348 |
|
---|
[1] | 349 | /* Process command line, if there is one. If not, ask user for info. */
|
---|
[128] | 350 | if (argc == 1) {
|
---|
| 351 | g_text_mode = FALSE;
|
---|
| 352 | setup_newt_stuff();
|
---|
[1645] | 353 | res = interactively_obtain_media_parameters_from_user(TRUE); /* yes, archiving */
|
---|
[128] | 354 | if (res) {
|
---|
| 355 | fatal_error
|
---|
| 356 | ("Syntax error. Please review the parameters you have supplied and try again.");
|
---|
| 357 | }
|
---|
| 358 | } else {
|
---|
[1645] | 359 | res = handle_incoming_parameters(argc, argv);
|
---|
[128] | 360 | if (res) {
|
---|
| 361 | printf
|
---|
[541] | 362 | ("Errors were detected in the command line you supplied.\n");
|
---|
[1319] | 363 | printf("Please review the log file - %s\n", MONDO_LOGFILE );
|
---|
[128] | 364 | log_msg(1, "Mondoarchive will now exit.");
|
---|
| 365 | finish(1);
|
---|
| 366 | }
|
---|
| 367 | setup_newt_stuff();
|
---|
[1] | 368 | }
|
---|
| 369 |
|
---|
| 370 | /* Finish configuring global structures */
|
---|
[1645] | 371 | if (post_param_configuration()) {
|
---|
[128] | 372 | fatal_error
|
---|
| 373 | ("Post-param initialization phase failed. Perhaps bad parameters were supplied to mondoarchive? Please review the documentation, error messages and logs. Exiting...");
|
---|
| 374 | }
|
---|
[1] | 375 |
|
---|
[128] | 376 | log_to_screen
|
---|
[541] | 377 | ("BusyBox's sources are available from http://www.busybox.net");
|
---|
[1] | 378 |
|
---|
[128] | 379 | /* If we're meant to backup then backup */
|
---|
| 380 | if (bkpinfo->backup_data) {
|
---|
[1645] | 381 | res = backup_data();
|
---|
[128] | 382 | retval += res;
|
---|
| 383 | if (res) {
|
---|
[3185] | 384 | mr_asprintf(say_at_end, "Data archived. Please check the logs, just as a precaution. ");
|
---|
[128] | 385 | } else {
|
---|
[3185] | 386 | mr_asprintf(say_at_end, "Data archived OK. ");
|
---|
[128] | 387 | }
|
---|
| 388 | }
|
---|
[1] | 389 |
|
---|
| 390 | /* If we're meant to verify then verify */
|
---|
[128] | 391 | if (bkpinfo->verify_data) {
|
---|
[1645] | 392 | res = verify_data();
|
---|
[128] | 393 | if (res < 0) {
|
---|
[3185] | 394 | mr_asprintf(tmp, "%d difference%c found.", -res,
|
---|
[128] | 395 | (-res != 1) ? 's' : ' ');
|
---|
[3185] | 396 | mr_asprintf(say_at_end, "%s", tmp);
|
---|
[128] | 397 | log_to_screen(tmp);
|
---|
[2241] | 398 | mr_free(tmp);
|
---|
[128] | 399 | res = 0;
|
---|
| 400 | }
|
---|
| 401 | retval += res;
|
---|
| 402 | }
|
---|
[1] | 403 |
|
---|
| 404 | /* Report result of entire operation (success? errors?) */
|
---|
[128] | 405 | if (!retval) {
|
---|
| 406 | mvaddstr_and_log_it(g_currentY++, 0,
|
---|
[541] | 407 | "Backup and/or verify ran to completion. Everything appears to be fine.");
|
---|
[128] | 408 | } else {
|
---|
| 409 | mvaddstr_and_log_it(g_currentY++, 0,
|
---|
[541] | 410 | "Backup and/or verify ran to completion. However, errors did occur.");
|
---|
[128] | 411 | }
|
---|
[1] | 412 |
|
---|
[1437] | 413 | if (does_file_exist(MINDI_CACHE"/mondorescue.iso")) {
|
---|
[128] | 414 | log_to_screen
|
---|
[1437] | 415 | (MINDI_CACHE"/mondorescue.iso, a boot/utility CD, is available if you want it.");
|
---|
[128] | 416 | }
|
---|
[1] | 417 |
|
---|
[1747] | 418 | if (length_of_file(MONDO_CACHE"/changed.files") > 2) {
|
---|
[128] | 419 | if (g_text_mode) {
|
---|
[1747] | 420 | log_to_screen("Type 'less "MONDO_CACHE"/changed.files' to see which files don't match the archives");
|
---|
[128] | 421 | } else {
|
---|
[1747] | 422 | log_msg(1, "Type 'less "MONDO_CACHE"/changed.files' to see which files don't match the archives");
|
---|
[128] | 423 | log_msg(2, "Calling popup_changelist_from_file()");
|
---|
[1747] | 424 | popup_changelist_from_file(MONDO_CACHE"/changed.files");
|
---|
[128] | 425 | log_msg(2, "Returned from popup_changelist_from_file()");
|
---|
| 426 | }
|
---|
| 427 | } else {
|
---|
[1747] | 428 | unlink(MONDO_CACHE"/changed.files");
|
---|
[128] | 429 | }
|
---|
[2211] | 430 | if (say_at_end != NULL) {
|
---|
| 431 | log_to_screen(say_at_end);
|
---|
| 432 | paranoid_free(say_at_end);
|
---|
| 433 | }
|
---|
[3185] | 434 | mr_asprintf(tmp, "umount %s/tmpfs", bkpinfo->tmpdir);
|
---|
[128] | 435 | run_program_and_log_output(tmp, TRUE);
|
---|
[2241] | 436 | mr_free(tmp);
|
---|
[1697] | 437 | if (bkpinfo->backup_media_type == usb) {
|
---|
| 438 | log_msg(1, "Unmounting USB device.");
|
---|
[3185] | 439 | mr_asprintf(tmp, "umount %s1", bkpinfo->media_device);
|
---|
[1697] | 440 | run_program_and_log_output(tmp, TRUE);
|
---|
[2241] | 441 | mr_free(tmp);
|
---|
[1697] | 442 | }
|
---|
[1] | 443 |
|
---|
[128] | 444 | run_program_and_log_output("mount", 2);
|
---|
[1] | 445 |
|
---|
[3060] | 446 | paranoid_system("rm -f "MONDO_CACHE"/last-backup.aborted");
|
---|
[128] | 447 | if (!retval) {
|
---|
[541] | 448 | printf("Mondoarchive ran OK.\n");
|
---|
[128] | 449 | } else {
|
---|
[541] | 450 | printf("Errors occurred during backup. Please check logfile.\n");
|
---|
[128] | 451 | }
|
---|
| 452 | distro_specific_kludges_at_end_of_mondoarchive();
|
---|
| 453 | set_signals(FALSE);
|
---|
[1644] | 454 |
|
---|
[128] | 455 | free_libmondo_global_strings();
|
---|
[1703] | 456 |
|
---|
[1] | 457 |
|
---|
[128] | 458 | if (!g_cdrom_drive_is_here) {
|
---|
| 459 | log_msg(10, "FYI, g_cdrom_drive_is_here was never used");
|
---|
| 460 | }
|
---|
| 461 | if (!g_dvd_drive_is_here) {
|
---|
| 462 | log_msg(10, "FYI, g_dvd_drive_is_here was never used");
|
---|
| 463 | }
|
---|
[1] | 464 |
|
---|
[810] | 465 | /* finalize log file with time stamp */
|
---|
[813] | 466 | log_msg(0, "Time finished: %s", mr_date());
|
---|
[810] | 467 |
|
---|
[3060] | 468 | if (chdir("/tmp")) {
|
---|
| 469 | // FIXME
|
---|
| 470 | }
|
---|
[1644] | 471 |
|
---|
[128] | 472 | if (!g_text_mode) {
|
---|
| 473 | popup_and_OK
|
---|
[541] | 474 | ("Mondo Archive has finished its run. Please press ENTER to return to the shell prompt.");
|
---|
| 475 | log_to_screen("See %s for details of backup run.", MONDO_LOGFILE);
|
---|
[128] | 476 | } else {
|
---|
[541] | 477 | printf("See %s for details of backup run.\n", MONDO_LOGFILE);
|
---|
[128] | 478 | }
|
---|
[1703] | 479 | finish(retval);
|
---|
[128] | 480 |
|
---|
| 481 | return EXIT_SUCCESS;
|
---|
[1] | 482 | }
|
---|