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