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