2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 1991-1998 University of Maryland at College Park
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of U.M. not be used in advertising or
11 * publicity pertaining to distribution of the software without specific,
12 * written prior permission. U.M. makes no representations about the
13 * suitability of this software for any purpose. It is provided "as is"
14 * without express or implied warranty.
16 * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
18 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 * Author: James da Silva, Systems Design and Analysis Group
24 * Computer Science Department
25 * University of Maryland at College Park
28 * $Id: amadmin.c,v 1.124 2006/07/26 15:17:37 martinea Exp $
30 * controlling process for the Amanda backup system
43 #include "timestamp.h"
47 int main(int argc, char **argv);
49 void force(int argc, char **argv);
50 void force_one(disk_t *dp);
51 void unforce(int argc, char **argv);
52 void unforce_one(disk_t *dp);
53 void force_bump(int argc, char **argv);
54 void force_bump_one(disk_t *dp);
55 void force_no_bump(int argc, char **argv);
56 void force_no_bump_one(disk_t *dp);
57 void unforce_bump(int argc, char **argv);
58 void unforce_bump_one(disk_t *dp);
59 void reuse(int argc, char **argv);
60 void noreuse(int argc, char **argv);
61 void info(int argc, char **argv);
62 void info_one(disk_t *dp);
63 void due(int argc, char **argv);
64 void due_one(disk_t *dp);
65 void find(int argc, char **argv);
66 void holding(int argc, char **argv);
67 void delete(int argc, char **argv);
68 void delete_one(disk_t *dp);
69 void balance(int argc, char **argv);
70 void tape(int argc, char **argv);
71 void bumpsize(int argc, char **argv);
72 void diskloop(int argc, char **argv, char *cmdname, void (*func)(disk_t *dp));
73 char *seqdatestr(int seq);
74 static int next_level0(disk_t *dp, info_t *info);
75 int bump_thresh(int level);
76 void export_db(int argc, char **argv);
77 void import_db(int argc, char **argv);
78 void disklist(int argc, char **argv);
79 void disklist_one(disk_t *dp);
80 void show_version(int argc, char **argv);
81 static void show_config(int argc, char **argv);
83 static char *conf_tapelist = NULL;
84 static char *displayunit;
85 static long int unitdivisor;
89 void (*fn)(int, char **);
92 { "version", show_version,
93 T_("\t\t\t\t\t# Show version info.") },
94 { "config", show_config,
95 T_("\t\t\t\t\t# Show configuration.") },
97 T_(" [<hostname> [<disks>]* ]+\t\t# Force level 0 at next run.") },
99 T_(" [<hostname> [<disks>]* ]+\t# Clear force command.") },
100 { "force-bump", force_bump,
101 T_(" [<hostname> [<disks>]* ]+\t# Force bump at next run.") },
102 { "force-no-bump", force_no_bump,
103 T_(" [<hostname> [<disks>]* ]+\t# Force no-bump at next run.") },
104 { "unforce-bump", unforce_bump,
105 T_(" [<hostname> [<disks>]* ]+\t# Clear bump command.") },
106 { "disklist", disklist,
107 T_(" [<hostname> [<disks>]* ]*\t# Debug disklist entries.") },
109 T_(" <tapelabel> ...\t\t # re-use this tape.") },
110 { "no-reuse", noreuse,
111 T_(" <tapelabel> ...\t # never re-use this tape.") },
113 T_(" [<hostname> [<disks>]* ]*\t # Show which tapes these dumps are on.") },
114 { "holding", holding,
115 T_(" {list [ -l ] |delete} [ <hostname> [ <disk> [ <datestamp> [ .. ] ] ] ]+\t # Show or delete holding disk contents.") },
117 T_(" [<hostname> [<disks>]* ]+ # Delete from database.") },
119 T_(" [<hostname> [<disks>]* ]*\t # Show current info records.") },
121 T_(" [<hostname> [<disks>]* ]*\t # Show due date.") },
122 { "balance", balance,
123 T_(" [--days <num>]\t\t # Show nightly dump size balance.") },
125 T_(" [--days <num>]\t\t # Show which tape is due next.") },
126 { "bumpsize", bumpsize,
127 T_("\t\t\t # Show current bump thresholds.") },
128 { "export", export_db,
129 T_(" [<hostname> [<disks>]* ]* # Export curinfo database to stdout.") },
130 { "import", import_db,
131 T_("\t\t\t\t # Import curinfo database from stdin.") },
133 #define NCMDS (int)(sizeof(cmdtab) / sizeof(cmdtab[0]))
143 config_overwrites_t *cfg_ovr = NULL;
146 * Configure program for internationalization:
147 * 1) Only set the message locale for now.
148 * 2) Set textdomain for all amanda related programs to "amanda"
149 * We don't want to be forced to support dozens of message catalogs.
151 setlocale(LC_MESSAGES, "C");
152 textdomain("amanda");
157 set_pname("amadmin");
159 /* Don't die when child closes pipe */
160 signal(SIGPIPE, SIG_IGN);
162 dbopen(DBG_SUBDIR_SERVER);
164 erroutput_type = ERR_INTERACTIVE;
166 cfg_ovr = extract_commandline_config_overwrites(&argc, &argv);
168 if(argc < 3) usage();
170 if(strcmp(argv[2],"version") == 0) {
171 show_version(argc, argv);
175 config_init(CONFIG_INIT_EXPLICIT_NAME, argv[1]);
176 apply_config_overwrites(cfg_ovr);
178 conf_diskfile = config_dir_relative(getconf_str(CNF_DISKFILE));
179 read_diskfile(conf_diskfile, &diskq);
180 amfree(conf_diskfile);
182 if (config_errors(NULL) >= CFGERR_WARNINGS) {
183 config_print_errors();
184 if (config_errors(NULL) >= CFGERR_ERRORS) {
185 g_critical(_("errors processing config file"));
189 dbrename(get_config_name(), DBG_SUBDIR_SERVER);
191 check_running_as(RUNNING_AS_DUMPUSER);
193 conf_tapelist = config_dir_relative(getconf_str(CNF_TAPELIST));
194 if(read_tapelist(conf_tapelist)) {
195 error(_("could not load tapelist \"%s\""), conf_tapelist);
198 /* conf_tapelist is not freed yet -- it may be used to write the
201 conf_infofile = config_dir_relative(getconf_str(CNF_INFOFILE));
202 if(open_infofile(conf_infofile)) {
203 error(_("could not open info db \"%s\""), conf_infofile);
206 amfree(conf_infofile);
208 displayunit = getconf_str(CNF_DISPLAYUNIT);
209 unitdivisor = getconf_unit_divisor();
211 for (i = 0; i < NCMDS; i++)
212 if (strcmp(argv[2], cmdtab[i].name) == 0) {
213 (*cmdtab[i].fn)(argc, argv);
217 g_fprintf(stderr, _("%s: unknown command \"%s\"\n"), argv[0], argv[2]);
223 amfree(conf_tapelist);
227 free_disklist(&diskq);
238 g_fprintf(stderr, _("\nUsage: %s%s <conf> <command> {<args>} [-o configoption]* ...\n"),
239 get_pname(), versionsuffix());
240 g_fprintf(stderr, _(" Valid <command>s are:\n"));
241 for (i = 0; i < NCMDS; i++)
242 g_fprintf(stderr, "\t%s%s\n", cmdtab[i].name, _(cmdtab[i].usage));
247 /* ----------------------------------------------- */
249 #define SECS_PER_DAY (24*60*60)
257 static char *dow[7] = {
266 time_t t = today + seq*SECS_PER_DAY;
272 g_snprintf(str, SIZEOF(str),
273 "%2d/%02d %3s", tm->tm_mon+1, tm->tm_mday, _(dow[tm->tm_wday]));
275 strcpy(str, _("BAD DATE"));
281 #define days_diff(a, b) (int)(((b) - (a) + SECS_PER_DAY) / SECS_PER_DAY)
283 /* when is next level 0 due? 0 = tonight, 1 = tommorrow, etc*/
289 if(dp->strategy == DS_NOFULL)
290 return 1; /* fake it */
291 if(info->inf[0].date < (time_t)0)
292 return 0; /* new disk */
294 return dp->dumpcycle - days_diff(info->inf[0].date, today);
297 /* ----------------------------------------------- */
304 void (*func)(disk_t *dp))
311 g_fprintf(stderr,_("%s: expecting \"%s [<hostname> [<disks>]* ]+\"\n"),
312 get_pname(), cmdname);
316 errstr = match_disklist(&diskq, argc-3, argv+3);
318 g_printf("%s", errstr);
322 for(dp = diskq.head; dp != NULL; dp = dp->next) {
329 g_fprintf(stderr,_("%s: no disk matched\n"),get_pname());
333 /* ----------------------------------------------- */
340 char *hostname = dp->host->hostname;
341 char *diskname = dp->name;
344 get_info(hostname, diskname, &info);
345 SET(info.command, FORCE_FULL);
346 if (ISSET(info.command, FORCE_BUMP)) {
347 CLR(info.command, FORCE_BUMP);
348 g_printf(_("%s: WARNING: %s:%s FORCE_BUMP command was cleared.\n"),
349 get_pname(), hostname, diskname);
351 if(put_info(hostname, diskname, &info) == 0) {
352 if (dp->strategy == DS_INCRONLY) {
353 g_printf(_("%s: %s:%s, full dump done offline, next dump will be at level 1.\n"),
354 get_pname(), hostname, diskname);
356 g_printf(_("%s: %s:%s is set to a forced level 0 at next run.\n"),
357 get_pname(), hostname, diskname);
360 g_fprintf(stderr, _("%s: %s:%s could not be forced.\n"),
361 get_pname(), hostname, diskname);
371 diskloop(argc, argv, "force", force_one);
375 /* ----------------------------------------------- */
382 char *hostname = dp->host->hostname;
383 char *diskname = dp->name;
386 get_info(hostname, diskname, &info);
387 if (ISSET(info.command, FORCE_FULL)) {
388 CLR(info.command, FORCE_FULL);
389 if(put_info(hostname, diskname, &info) == 0){
390 g_printf(_("%s: force command for %s:%s cleared.\n"),
391 get_pname(), hostname, diskname);
394 _("%s: force command for %s:%s could not be cleared.\n"),
395 get_pname(), hostname, diskname);
399 g_printf(_("%s: no force command outstanding for %s:%s, unchanged.\n"),
400 get_pname(), hostname, diskname);
409 diskloop(argc, argv, "unforce", unforce_one);
413 /* ----------------------------------------------- */
420 char *hostname = dp->host->hostname;
421 char *diskname = dp->name;
424 get_info(hostname, diskname, &info);
425 SET(info.command, FORCE_BUMP);
426 if (ISSET(info.command, FORCE_NO_BUMP)) {
427 CLR(info.command, FORCE_NO_BUMP);
428 g_printf(_("%s: WARNING: %s:%s FORCE_NO_BUMP command was cleared.\n"),
429 get_pname(), hostname, diskname);
431 if (ISSET(info.command, FORCE_FULL)) {
432 CLR(info.command, FORCE_FULL);
433 g_printf(_("%s: WARNING: %s:%s FORCE_FULL command was cleared.\n"),
434 get_pname(), hostname, diskname);
436 if(put_info(hostname, diskname, &info) == 0) {
437 g_printf(_("%s: %s:%s is set to bump at next run.\n"),
438 get_pname(), hostname, diskname);
440 g_fprintf(stderr, _("%s: %s:%s could not be forced to bump.\n"),
441 get_pname(), hostname, diskname);
451 diskloop(argc, argv, "force-bump", force_bump_one);
455 /* ----------------------------------------------- */
462 char *hostname = dp->host->hostname;
463 char *diskname = dp->name;
466 get_info(hostname, diskname, &info);
467 SET(info.command, FORCE_NO_BUMP);
468 if (ISSET(info.command, FORCE_BUMP)) {
469 CLR(info.command, FORCE_BUMP);
470 g_printf(_("%s: WARNING: %s:%s FORCE_BUMP command was cleared.\n"),
471 get_pname(), hostname, diskname);
473 if(put_info(hostname, diskname, &info) == 0) {
474 g_printf(_("%s: %s:%s is set to not bump at next run.\n"),
475 get_pname(), hostname, diskname);
477 g_fprintf(stderr, _("%s: %s:%s could not be force to not bump.\n"),
478 get_pname(), hostname, diskname);
488 diskloop(argc, argv, "force-no-bump", force_no_bump_one);
492 /* ----------------------------------------------- */
499 char *hostname = dp->host->hostname;
500 char *diskname = dp->name;
503 get_info(hostname, diskname, &info);
504 if (ISSET(info.command, FORCE_BUMP|FORCE_NO_BUMP)) {
505 CLR(info.command, FORCE_BUMP|FORCE_NO_BUMP);
506 if(put_info(hostname, diskname, &info) == 0) {
507 g_printf(_("%s: bump command for %s:%s cleared.\n"),
508 get_pname(), hostname, diskname);
510 g_fprintf(stderr, _("%s: %s:%s bump command could not be cleared.\n"),
511 get_pname(), hostname, diskname);
515 g_printf(_("%s: no bump command outstanding for %s:%s, unchanged.\n"),
516 get_pname(), hostname, diskname);
526 diskloop(argc, argv, "unforce-bump", unforce_bump_one);
530 /* ----------------------------------------------- */
541 g_fprintf(stderr,_("%s: expecting \"reuse <tapelabel> ...\"\n"),
546 for(count=3; count< argc; count++) {
547 tp = lookup_tapelabel(argv[count]);
549 g_fprintf(stderr, _("reuse: tape label %s not found in tapelist.\n"),
553 if( tp->reuse == 0 ) {
555 g_printf(_("%s: marking tape %s as reusable.\n"),
556 get_pname(), argv[count]);
558 g_fprintf(stderr, _("%s: tape %s already reusable.\n"),
559 get_pname(), argv[count]);
563 if(write_tapelist(conf_tapelist)) {
564 error(_("could not write tapelist \"%s\""), conf_tapelist);
578 g_fprintf(stderr,_("%s: expecting \"no-reuse <tapelabel> ...\"\n"),
583 for(count=3; count< argc; count++) {
584 tp = lookup_tapelabel(argv[count]);
586 g_fprintf(stderr, _("no-reuse: tape label %s not found in tapelist.\n"),
590 if( tp->reuse == 1 ) {
592 g_printf(_("%s: marking tape %s as not reusable.\n"),
593 get_pname(), argv[count]);
595 g_fprintf(stderr, _("%s: tape %s already not reusable.\n"),
596 get_pname(), argv[count]);
600 if(write_tapelist(conf_tapelist)) {
601 error(_("could not write tapelist \"%s\""), conf_tapelist);
607 /* ----------------------------------------------- */
615 char *hostname = dp->host->hostname;
616 char *diskname = dp->name;
619 if(get_info(hostname, diskname, &info)) {
620 g_printf(_("%s: %s:%s NOT currently in database.\n"),
621 get_pname(), hostname, diskname);
626 if(del_info(hostname, diskname)) {
627 error(_("couldn't delete %s:%s from database: %s"),
628 hostname, diskname, strerror(errno));
631 g_printf(_("%s: %s:%s deleted from curinfo database.\n"),
632 get_pname(), hostname, diskname);
642 diskloop(argc, argv, "delete", delete_one);
646 _("%s: NOTE: you'll have to remove these from the disklist yourself.\n"),
650 /* ----------------------------------------------- */
661 get_info(dp->host->hostname, dp->name, &info);
663 g_printf(_("\nCurrent info for %s %s:\n"), dp->host->hostname, dp->name);
664 if (ISSET(info.command, FORCE_FULL))
665 g_printf(_(" (Forcing to level 0 dump at next run)\n"));
666 if (ISSET(info.command, FORCE_BUMP))
667 g_printf(_(" (Forcing bump at next run)\n"));
668 if (ISSET(info.command, FORCE_NO_BUMP))
669 g_printf(_(" (Forcing no-bump at next run)\n"));
670 g_printf(_(" Stats: dump rates (kps), Full: %5.1lf, %5.1lf, %5.1lf\n"),
671 info.full.rate[0], info.full.rate[1], info.full.rate[2]);
672 g_printf(_(" Incremental: %5.1lf, %5.1lf, %5.1lf\n"),
673 info.incr.rate[0], info.incr.rate[1], info.incr.rate[2]);
674 g_printf(_(" compressed size, Full: %5.1lf%%,%5.1lf%%,%5.1lf%%\n"),
675 info.full.comp[0]*100, info.full.comp[1]*100, info.full.comp[2]*100);
676 g_printf(_(" Incremental: %5.1lf%%,%5.1lf%%,%5.1lf%%\n"),
677 info.incr.comp[0]*100, info.incr.comp[1]*100, info.incr.comp[2]*100);
679 g_printf(_(" Dumps: lev datestmp tape file origK compK secs\n"));
680 for(lev = 0, sp = &info.inf[0]; lev < 9; lev++, sp++) {
681 if(sp->date < (time_t)0 && sp->label[0] == '\0') continue;
682 tm = localtime(&sp->date);
684 g_printf(_(" %d %04d%02d%02d %-15s %lld %lld %lld %jd\n"),
685 lev, tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
687 (long long)sp->filenum,
689 (long long)sp->csize,
692 g_printf(_(" %d BAD-DATE %-15s %lld %lld %lld %jd\n"),
695 (long long)sp->filenum,
697 (long long)sp->csize,
712 diskloop(argc, argv, "info", info_one);
714 for(dp = diskq.head; dp != NULL; dp = dp->next)
718 /* ----------------------------------------------- */
729 if(get_info(hp->hostname, dp->name, &info)) {
730 g_printf(_("new disk %s:%s ignored.\n"), hp->hostname, dp->name);
733 days = next_level0(dp, &info);
735 g_printf(_("Overdue %2d day%s %s:%s\n"),
736 -days, (-days == 1) ? ": " : "s:",
737 hp->hostname, dp->name);
740 g_printf(_("Due today: %s:%s\n"), hp->hostname, dp->name);
743 g_printf(_("Due in %2d day%s %s:%s\n"), days,
744 (days == 1) ? ": " : "s:",
745 hp->hostname, dp->name);
759 diskloop(argc, argv, "due", due_one);
761 for(dp = diskq.head; dp != NULL; dp = dp->next)
765 /* ----------------------------------------------- */
779 if(argc > 4 && strcmp(argv[3],"--days") == 0) {
780 nb_days = atoi(argv[4]);
782 g_printf(_("days must be an integer bigger than 0\n"));
789 runtapes = getconf_int(CNF_RUNTAPES);
790 tp = lookup_last_reusable_tape(0);
793 for ( j=0 ; j < nb_days ; j++ ) {
795 for ( i=0 ; i < runtapes ; i++ ) {
797 g_fprintf(stdout, _("The next Amanda run should go onto "));
799 if (nb_new_tape > 0) {
800 if (nb_new_tape == 1)
801 g_fprintf(stdout, _("1 new tape.\n"));
803 g_fprintf(stdout, _("%d new tapes.\n"), nb_new_tape);
804 g_fprintf(stdout, " ");
807 g_fprintf(stdout, _("tape %s or a new tape.\n"), tp->label);
809 g_fprintf(stdout, " ");
815 tp = lookup_last_reusable_tape(skip);
817 if (nb_new_tape > 0) {
818 if (nb_new_tape == 1)
819 g_fprintf(stdout, _("1 new tape.\n"));
821 g_fprintf(stdout, _("%d new tapes.\n"), nb_new_tape);
825 print_new_tapes(stdout, nb_days * runtapes);
828 /* ----------------------------------------------- */
836 struct balance_stats {
838 off_t origsize, outsize;
840 int conf_runspercycle, conf_dumpcycle;
841 int seq, runs_per_cycle, overdue, max_overdue;
842 int later, total, balance, distinct;
843 double fseq, disk_dumpcycle;
845 off_t total_balanced, balanced;
849 conf_dumpcycle = getconf_int(CNF_DUMPCYCLE);
850 conf_runspercycle = getconf_int(CNF_RUNSPERCYCLE);
851 later = conf_dumpcycle;
855 if(argc > 4 && strcmp(argv[3],"--days") == 0) {
856 later = atoi(argv[4]);
857 if(later < 0) later = conf_dumpcycle;
859 if(later > 10000) later = 10000;
861 if(conf_runspercycle == 0) {
862 runs_per_cycle = conf_dumpcycle;
863 } else if(conf_runspercycle == -1 ) {
864 runs_per_cycle = guess_runs_from_tapelist();
866 runs_per_cycle = conf_runspercycle;
868 if (runs_per_cycle <= 0) {
874 distinct = later + 3;
876 sp = (struct balance_stats *)
877 alloc(SIZEOF(struct balance_stats) * (distinct+1));
879 for(seq=0; seq <= distinct; seq++) {
881 sp[seq].origsize = sp[seq].outsize = (off_t)0;
884 for(dp = diskq.head; dp != NULL; dp = dp->next) {
885 if(get_info(dp->host->hostname, dp->name, &info)) {
886 g_printf(_("new disk %s:%s ignored.\n"), dp->host->hostname, dp->name);
889 if (dp->strategy == DS_NOFULL) {
892 sp[distinct].disks++;
893 sp[distinct].origsize += info.inf[0].size/(off_t)unitdivisor;
894 sp[distinct].outsize += info.inf[0].csize/(off_t)unitdivisor;
897 if(dp->dumpcycle == 0) {
898 sp[balance].origsize += (info.inf[0].size/(off_t)unitdivisor) * (off_t)runs_per_cycle;
899 sp[balance].outsize += (info.inf[0].csize/(off_t)unitdivisor) * (off_t)runs_per_cycle;
902 sp[balance].origsize += (info.inf[0].size/(off_t)unitdivisor) *
903 (off_t)(conf_dumpcycle / dp->dumpcycle);
904 sp[balance].outsize += (info.inf[0].csize/(off_t)unitdivisor) *
905 (off_t)(conf_dumpcycle / dp->dumpcycle);
908 disk_dumpcycle = (double)dp->dumpcycle;
909 if(dp->dumpcycle <= 0)
910 disk_dumpcycle = ((double)conf_dumpcycle) / ((double)runs_per_cycle);
912 seq = next_level0(dp, &info);
917 if (-seq > max_overdue)
927 sp[seq].origsize += info.inf[0].size/(off_t)unitdivisor;
928 sp[seq].outsize += info.inf[0].csize/(off_t)unitdivisor;
932 sp[total].origsize += info.inf[0].size/(off_t)unitdivisor;
933 sp[total].outsize += info.inf[0].csize/(off_t)unitdivisor;
936 /* See, if there's another run in this dumpcycle */
937 fseq += disk_dumpcycle;
939 } while (seq < later);
942 if(sp[total].outsize == (off_t)0 && sp[later].outsize == (off_t)0) {
943 g_printf(_("\nNo data to report on yet.\n"));
948 balanced = sp[balance].outsize / (off_t)runs_per_cycle;
949 if(conf_dumpcycle == later) {
950 total_balanced = sp[total].outsize / (off_t)runs_per_cycle;
953 total_balanced = (((sp[total].outsize/(off_t)1024) * (off_t)conf_dumpcycle)
954 / (off_t)(runs_per_cycle * later)) * (off_t)1024;
958 g_printf(_("\n due-date #fs orig %cB out %cB balance\n"),
959 displayunit[0], displayunit[0]);
960 g_printf("----------------------------------------------\n");
961 for(seq = 0; seq < later; seq++) {
962 if(sp[seq].disks == 0 &&
963 ((seq > 0 && sp[seq-1].disks == 0) ||
964 ((seq < later-1) && sp[seq+1].disks == 0))) {
972 g_printf(_("%-9.9s %3d %10lld %10lld "),
973 seqdatestr(seq), sp[seq].disks,
974 (long long)sp[seq].origsize,
975 (long long)sp[seq].outsize);
976 if(!sp[seq].outsize) g_printf(" --- \n");
977 else g_printf(_("%+8.1lf%%\n"),
978 (((double)sp[seq].outsize - (double)balanced) * 100.0 /
983 if(sp[later].disks != 0) {
984 g_printf(_("later %3d %10lld %10lld "),
986 (long long)sp[later].origsize,
987 (long long)sp[later].outsize);
988 if(!sp[later].outsize) g_printf(" --- \n");
989 else g_printf(_("%+8.1lf%%\n"),
990 (((double)sp[later].outsize - (double)balanced) * 100.0 /
993 g_printf("----------------------------------------------\n");
994 g_printf(_("TOTAL %3d %10lld %10lld %9lld\n"),
996 (long long)sp[total].origsize,
997 (long long)sp[total].outsize,
998 (long long)total_balanced);
999 if (sp[balance].origsize != sp[total].origsize ||
1000 sp[balance].outsize != sp[total].outsize ||
1001 balanced != total_balanced) {
1002 g_printf(_("BALANCED %10lld %10lld %9lld\n"),
1003 (long long)sp[balance].origsize,
1004 (long long)sp[balance].outsize,
1005 (long long)balanced);
1007 if (sp[distinct].disks != sp[total].disks) {
1008 g_printf(_("DISTINCT %3d %10lld %10lld\n"),
1010 (long long)sp[distinct].origsize,
1011 (long long)sp[distinct].outsize);
1013 g_printf(plural(_(" (estimated %d run per dumpcycle)\n"),
1014 _(" (estimated %d runs per dumpcycle)\n"),
1018 g_printf(plural(_(" (%d filesystem overdue."),
1019 _(" (%d filesystems overdue."), overdue),
1021 g_printf(plural(_(" The most being overdue %d day.)\n"),
1022 _(" The most being overdue %d days.)\n"), max_overdue),
1029 /* ----------------------------------------------- */
1037 char *sort_order = NULL;
1038 find_result_t *output_find;
1043 _("%s: expecting \"find [--sort <hkdlpbfw>] [hostname [<disk>]]*\"\n"),
1049 sort_order = newstralloc(sort_order, DEFAULT_SORT_ORDER);
1050 if(argc > 4 && strcmp(argv[3],"--sort") == 0) {
1051 size_t i, valid_sort=1;
1053 for(i = strlen(argv[4]); i > 0; i--) {
1054 switch (argv[4][i - 1]) {
1072 default: valid_sort=0;
1076 sort_order = newstralloc(sort_order, argv[4]);
1078 g_printf(_("Invalid sort order: %s\n"), argv[4]);
1079 g_printf(_("Use default sort order: %s\n"), sort_order);
1085 errstr = match_disklist(&diskq, argc-(start_argc-1), argv+(start_argc-1));
1087 g_printf("%s", errstr);
1091 output_find = find_dump(&diskq);
1092 if(argc-(start_argc-1) > 0) {
1093 free_find_result(&output_find);
1094 errstr = match_disklist(&diskq, argc-(start_argc-1),
1095 argv+(start_argc-1));
1097 g_printf("%s", errstr);
1100 output_find = find_dump(NULL);
1103 sort_find_result(sort_order, &output_find);
1104 print_find_result(output_find);
1105 free_find_result(&output_find);
1111 /* ------------------------ */
1119 GSList * file_list = NULL;
1123 flags = CMDLINE_PARSE_DATESTAMP;
1124 if (allow_empty) flags |= CMDLINE_EMPTY_TO_WILDCARD;
1125 dumplist = cmdline_parse_dumpspecs(argc, argv, flags);
1127 file_list = cmdline_match_holding(dumplist);
1128 dumpspec_list_free(dumplist);
1133 /* Given a file header, find the history element in curinfo most likely
1134 * corresponding to that dump (this is not an exact science).
1136 * @param info: the info_t element for this DLE
1137 * @param file: the header of the file
1138 * @returns: index of the matching history element, or -1 if not found
1141 holding_file_find_history(
1145 int matching_hist_idx = -1;
1149 /* Begin by trying to find the history element matching this dump.
1150 * The datestamp on the dump is for the entire run of amdump, while the
1151 * 'date' in the history element of 'info' is the time the dump itself
1152 * began. A matching history element, then, is the earliest element
1153 * with a 'date' equal to or later than the date of the dumpfile.
1155 * We compare using formatted datestamps; even using seconds since epoch,
1156 * we would still face timezone issues, and have to do a reverse (timezone
1157 * to gmt) translation.
1160 /* get to the end of the history list and search backward */
1161 for (nhist = 0; info->history[nhist].level > -1; nhist++) /* empty loop */;
1162 for (i = nhist-1; i > -1; i--) {
1163 char *info_datestamp = get_timestamp_from_time(info->history[i].date);
1164 int order = strcmp(file->datestamp, info_datestamp);
1165 amfree(info_datestamp);
1168 /* only a match if the levels are equal */
1169 if (info->history[i].level == file->dumplevel) {
1170 matching_hist_idx = i;
1176 return matching_hist_idx;
1179 /* A holding file is 'outdated' if a subsequent dump of the same DLE was made
1180 * at the same level or a lower leve; for example, a level 2 dump is outdated if
1181 * there is a subsequent level 2, or a subsequent level 0.
1183 * @param file: the header of the file
1184 * @returns: true if the file is outdated
1187 holding_file_is_outdated(
1191 int matching_hist_idx;
1193 if (get_info(file->name, file->disk, &info) == -1) {
1194 return 0; /* assume it's not outdated */
1197 /* if the last level is less than the level of this dump, then
1199 if (info.last_level < file->dumplevel)
1202 /* otherwise, we need to see if this dump is the last at its level */
1203 matching_hist_idx = holding_file_find_history(&info, file);
1204 if (matching_hist_idx == -1) {
1205 return 0; /* assume it's not outdated */
1208 /* compare the date of the history element with the most recent date
1209 * for this level. If they match, then this is the last dump at this
1210 * level, and we checked above for more recent lower-level dumps, so
1211 * the dump is not outdated. */
1212 if (info.history[matching_hist_idx].date ==
1213 info.inf[info.history[matching_hist_idx].level].date) {
1221 remove_holding_file_from_catalog(
1224 static int warnings_printed; /* only print once per invocation */
1227 int matching_hist_idx = -1;
1228 history_t matching_hist; /* will be a copy */
1231 if (!holding_file_get_dumpfile(filename, &file)) {
1232 g_printf(_("Could not read holding file %s\n"), filename);
1236 if (get_info(file.name, file.disk, &info) == -1) {
1237 g_printf(_("WARNING: No curinfo record for %s:%s\n"), file.name, file.disk);
1238 dumpfile_free_data(&file);
1239 return 1; /* not an error */
1242 matching_hist_idx = holding_file_find_history(&info, &file);
1244 if (matching_hist_idx == -1) {
1245 g_printf(_("WARNING: No dump matching %s found in curinfo.\n"), filename);
1246 dumpfile_free_data(&file);
1247 return 1; /* not an error */
1251 matching_hist = info.history[matching_hist_idx];
1253 /* Remove the history element itself before doing the stats */
1254 for (i = matching_hist_idx; i < NB_HISTORY; i++) {
1255 info.history[i] = info.history[i+1];
1257 info.history[NB_HISTORY].level = -1;
1259 /* Remove stats for that history element, if necessary. Doing so
1260 * will result in an inconsistent set of backups, so we warn the
1261 * user and adjust last_level to make the next dump get us a
1262 * consistent picture. */
1263 if (matching_hist.date == info.inf[matching_hist.level].date) {
1264 /* search for an earlier dump at this level */
1265 for (i = matching_hist_idx; info.history[i].level > -1; i++) {
1266 if (info.history[i].level == matching_hist.level)
1270 if (info.history[i].level < 0) {
1271 /* not found => zero it out */
1272 info.inf[matching_hist.level].date = (time_t)-1; /* flag as not set */
1273 info.inf[matching_hist.level].label[0] = '\0';
1275 /* found => reconstruct stats as best we can */
1276 info.inf[matching_hist.level].size = info.history[i].size;
1277 info.inf[matching_hist.level].csize = info.history[i].csize;
1278 info.inf[matching_hist.level].secs = info.history[i].secs;
1279 info.inf[matching_hist.level].date = info.history[i].date;
1280 info.inf[matching_hist.level].filenum = 0; /* we don't know */
1281 info.inf[matching_hist.level].label[0] = '\0'; /* we don't know */
1284 /* set last_level to the level we just deleted, and set command
1285 * appropriately to make sure planner does a new dump at this level
1287 info.last_level = matching_hist.level;
1288 if (info.last_level == 0) {
1289 g_printf(_("WARNING: Deleting the most recent full dump; forcing a full dump at next run.\n"));
1290 SET(info.command, FORCE_FULL);
1292 g_printf(_("WARNING: Deleting the most recent level %d dump; forcing a level %d dump or \nWARNING: lower at next run.\n"),
1293 info.last_level, info.last_level);
1294 SET(info.command, FORCE_NO_BUMP);
1297 /* Search for and display any subsequent runs that depended on this one */
1298 warnings_printed = 0;
1299 for (i = matching_hist_idx-1; i >= 0; i--) {
1301 if (info.history[i].level <= matching_hist.level) break;
1303 datestamp = get_timestamp_from_time(info.history[i].date);
1304 g_printf(_("WARNING: Level %d dump made %s can no longer be accurately restored.\n"),
1305 info.history[i].level, datestamp);
1308 warnings_printed = 1;
1310 if (warnings_printed)
1311 g_printf(_("WARNING: (note, dates shown above are for dumps, and may be later than the\nWARNING: corresponding run date)\n"));
1314 /* recalculate consecutive_runs based on the history: find the first run
1315 * at this level, and then count the consecutive runs at that level. This
1316 * number may be zero (if we just deleted the last run at this level) */
1317 info.consecutive_runs = 0;
1318 for (i = 0; info.history[i].level >= 0; i++) {
1319 if (info.history[i].level == info.last_level) break;
1321 while (info.history[i+info.consecutive_runs].level == info.last_level)
1322 info.consecutive_runs++;
1324 /* this function doesn't touch the performance stats */
1326 /* write out the changes */
1327 if (put_info(file.name, file.disk, &info) == -1) {
1328 g_printf(_("Could not write curinfo record for %s:%s\n"), file.name, file.disk);
1329 dumpfile_free_data(&file);
1333 dumpfile_free_data(&file);
1344 enum { HOLDING_USAGE, HOLDING_LIST, HOLDING_DELETE } action = HOLDING_USAGE;
1346 int outdated_list = 0;
1350 action = HOLDING_USAGE;
1351 else if (strcmp(argv[3], "list") == 0 && argc >= 4)
1352 action = HOLDING_LIST;
1353 else if (strcmp(argv[3], "delete") == 0 && argc > 4)
1354 action = HOLDING_DELETE;
1359 _("%s: expecting \"holding list [-l] [-d]\" or \"holding delete <host> [ .. ]\"\n"),
1365 argc -= 4; argv += 4;
1366 while (argc && argv[0][0] == '-') {
1367 switch (argv[0][1]) {
1371 case 'd': /* have to use '-d', and not '-o', because of parse_config */
1375 g_fprintf(stderr, _("Unknown option -%c\n"), argv[0][1]);
1384 g_printf("%-10s %-2s %-4s %s\n",
1385 _("size (kB)"), _("lv"), _("outd"), _("dump specification"));
1388 file_list = get_file_list(argc, argv, 1);
1389 for (li = file_list; li != NULL; li = li->next) {
1393 if (!holding_file_get_dumpfile((char *)li->data, &file)) {
1394 g_fprintf(stderr, _("Error reading %s\n"), (char *)li->data);
1398 is_outdated = holding_file_is_outdated(&file);
1400 dumpstr = cmdline_format_dumpspec_components(file.name, file.disk, file.datestamp, NULL);
1401 /* only print this entry if we're printing everything, or if it's outdated and
1402 * we're only printing outdated files (-o) */
1403 if (!outdated_list || is_outdated) {
1405 g_printf("%-10lld %-2d %-4s %s\n",
1406 (long long)holding_file_size((char *)li->data, 0),
1408 is_outdated? " *":"",
1411 g_printf("%s\n", dumpstr);
1415 dumpfile_free_data(&file);
1417 g_slist_free_full(file_list);
1420 case HOLDING_DELETE:
1421 argc -= 4; argv += 4;
1423 file_list = get_file_list(argc, argv, 0);
1424 for (li = file_list; li != NULL; li = li->next) {
1425 g_fprintf(stderr, _("Deleting '%s'\n"), (char *)li->data);
1426 /* remove it from the catalog */
1427 if (!remove_holding_file_from_catalog((char *)li->data))
1431 if (!holding_file_unlink((char *)li->data)) {
1432 error(_("Could not delete '%s'"), (char *)li->data);
1435 g_slist_free_full(file_list);
1441 /* ------------------------ */
1444 /* shared code with planner.c */
1450 int bump = getconf_int(CNF_BUMPSIZE);
1451 double mult = getconf_real(CNF_BUMPMULT);
1454 bump = (int)((double)bump * mult);
1464 int conf_bumppercent = getconf_int(CNF_BUMPPERCENT);
1465 double conf_bumpmult = getconf_real(CNF_BUMPMULT);
1467 (void)argc; /* Quiet unused parameter warning */
1468 (void)argv; /* Quiet unused parameter warning */
1470 g_printf(_("Current bump parameters:\n"));
1471 if(conf_bumppercent == 0) {
1472 g_printf(_(" bumpsize %5d KB\t- minimum savings (threshold) to bump level 1 -> 2\n"),
1473 getconf_int(CNF_BUMPSIZE));
1474 g_printf(_(" bumpdays %5d\t- minimum days at each level\n"),
1475 getconf_int(CNF_BUMPDAYS));
1476 g_printf(_(" bumpmult %5.5lg\t- threshold = bumpsize * bumpmult**(level-1)\n\n"),
1479 g_printf(_(" Bump -> To Threshold\n"));
1480 for(l = 1; l < 9; l++)
1481 g_printf(_("\t%d -> %d %9d KB\n"), l, l+1, bump_thresh(l));
1485 double bumppercent = (double)conf_bumppercent;
1487 g_printf(_(" bumppercent %3d %%\t- minimum savings (threshold) to bump level 1 -> 2\n"),
1489 g_printf(_(" bumpdays %5d\t- minimum days at each level\n"),
1490 getconf_int(CNF_BUMPDAYS));
1491 g_printf(_(" bumpmult %5.5lg\t- threshold = disk_size * bumppercent * bumpmult**(level-1)\n\n"),
1493 g_printf(_(" Bump -> To Threshold\n"));
1494 for(l = 1; l < 9; l++) {
1495 g_printf(_("\t%d -> %d %7.2lf %%\n"), l, l+1, bumppercent);
1496 bumppercent *= conf_bumpmult;
1497 if(bumppercent >= 100.000) { bumppercent = 100.0;}
1503 /* ----------------------------------------------- */
1505 void export_one(disk_t *dp);
1514 char hostname[MAX_HOSTNAME_LENGTH+1];
1517 g_printf(_("CURINFO Version %s CONF %s\n"), version(), getconf_str(CNF_ORG));
1520 if(gethostname(hostname, SIZEOF(hostname)-1) == -1) {
1521 error(_("could not determine host name: %s\n"), strerror(errno));
1524 hostname[SIZEOF(hostname)-1] = '\0';
1525 g_printf(_("# Generated by:\n# host: %s\n# date: %s"),
1526 hostname, ctime(&curtime));
1528 g_printf(_("# command:"));
1529 for(i = 0; i < argc; i++)
1530 g_printf(_(" %s"), argv[i]);
1532 g_printf(_("\n# This file can be merged back in with \"amadmin import\".\n"));
1533 g_printf(_("# Edit only with care.\n"));
1536 diskloop(argc, argv, "export", export_one);
1537 else for(dp = diskq.head; dp != NULL; dp = dp->next)
1548 if(get_info(dp->host->hostname, dp->name, &info)) {
1549 g_fprintf(stderr, _("Warning: no curinfo record for %s:%s\n"),
1550 dp->host->hostname, dp->name);
1553 g_printf(_("host: %s\ndisk: %s\n"), dp->host->hostname, dp->name);
1554 g_printf(_("command: %u\n"), info.command);
1555 g_printf(_("last_level: %d\n"),info.last_level);
1556 g_printf(_("consecutive_runs: %d\n"),info.consecutive_runs);
1557 g_printf(_("full-rate:"));
1558 for(i=0;i<AVG_COUNT;i++) g_printf(_(" %lf"), info.full.rate[i]);
1559 g_printf(_("\nfull-comp:"));
1560 for(i=0;i<AVG_COUNT;i++) g_printf(_(" %lf"), info.full.comp[i]);
1562 g_printf(_("\nincr-rate:"));
1563 for(i=0;i<AVG_COUNT;i++) g_printf(_(" %lf"), info.incr.rate[i]);
1564 g_printf(_("\nincr-comp:"));
1565 for(i=0;i<AVG_COUNT;i++) g_printf(_(" %lf"), info.incr.comp[i]);
1567 for(l=0;l<DUMP_LEVELS;l++) {
1568 if(info.inf[l].date < (time_t)0 && info.inf[l].label[0] == '\0') continue;
1569 g_printf(_("stats: %d %lld %lld %jd %jd %lld %s\n"), l,
1570 (long long)info.inf[l].size,
1571 (long long)info.inf[l].csize,
1572 (intmax_t)info.inf[l].secs,
1573 (intmax_t)info.inf[l].date,
1574 (long long)info.inf[l].filenum,
1577 for(l=0;info.history[l].level > -1;l++) {
1578 g_printf(_("history: %d %lld %lld %jd\n"),
1579 info.history[l].level,
1580 (long long)info.history[l].size,
1581 (long long)info.history[l].csize,
1582 (intmax_t)info.history[l].date);
1587 /* ----------------------------------------------- */
1589 int import_one(void);
1590 char *impget_line(void);
1608 (void)argc; /* Quiet unused parameter warning */
1609 (void)argv; /* Quiet unused parameter warning */
1611 /* process header line */
1613 if((line = agets(stdin)) == NULL) {
1614 g_fprintf(stderr, _("%s: empty input.\n"), get_pname());
1622 if(strncmp_const_skip(s - 1, "CURINFO Version", s, ch) != 0) {
1626 skip_whitespace(s, ch);
1628 || sscanf(s - 1, "%d.%d.%d", &vers_maj, &vers_min, &vers_patch) != 3) {
1632 skip_integer(s, ch); /* skip over major */
1637 skip_integer(s, ch); /* skip over minor */
1642 skip_integer(s, ch); /* skip over patch */
1648 skip_non_whitespace(s, ch);
1652 skip_whitespace(s, ch); /* find the org keyword */
1653 if(ch == '\0' || strncmp_const_skip(s - 1, "CONF", s, ch) != 0) {
1659 skip_whitespace(s, ch); /* find the org string */
1666 newer = (vers_maj != VERSION_MAJOR)? vers_maj > VERSION_MAJOR :
1667 (vers_min != VERSION_MINOR)? vers_min > VERSION_MINOR :
1668 vers_patch > VERSION_PATCH;
1671 _("%s: WARNING: input is from newer Amanda version: %d.%d.%d.\n"),
1672 get_pname(), vers_maj, vers_min, vers_patch);
1675 if(strcmp(org, getconf_str(CNF_ORG)) != 0) {
1676 g_fprintf(stderr, _("%s: WARNING: input is from different org: %s\n"),
1689 /*@i@*/ amfree(line);
1690 g_fprintf(stderr, _("%s: bad CURINFO header line in input: %s.\n"),
1692 g_fprintf(stderr, _(" Was the input in \"amadmin export\" format?\n"));
1707 char *hostname = NULL;
1708 char *diskname = NULL;
1709 long long off_t_tmp;
1710 long long time_t_tmp;
1712 memset(&info, 0, SIZEOF(info_t));
1714 for(level = 0; level < DUMP_LEVELS; level++) {
1715 info.inf[level].date = (time_t)-1;
1718 /* get host: disk: command: lines */
1720 hostname = diskname = NULL;
1722 if((line = impget_line()) == NULL) return 0; /* nothing there */
1726 skip_whitespace(s, ch);
1727 if(ch == '\0' || strncmp_const_skip(s - 1, "host:", s, ch) != 0) goto parse_err;
1728 skip_whitespace(s, ch);
1729 if(ch == '\0') goto parse_err;
1731 skip_non_whitespace(s, ch);
1733 hostname = stralloc(fp);
1736 skip_whitespace(s, ch);
1739 if((line = impget_line()) == NULL) goto shortfile_err;
1742 skip_whitespace(s, ch);
1744 if(strncmp_const_skip(s - 1, "disk:", s, ch) != 0) goto parse_err;
1745 skip_whitespace(s, ch);
1746 if(ch == '\0') goto parse_err;
1748 skip_non_whitespace(s, ch);
1750 diskname = stralloc(fp);
1754 if((line = impget_line()) == NULL) goto shortfile_err;
1755 if(sscanf(line, "command: %u", &info.command) != 1) goto parse_err;
1757 /* get last_level and consecutive_runs */
1760 if((line = impget_line()) == NULL) goto shortfile_err;
1761 rc = sscanf(line, "last_level: %d", &info.last_level);
1764 if((line = impget_line()) == NULL) goto shortfile_err;
1765 if(sscanf(line, "consecutive_runs: %d", &info.consecutive_runs) != 1) goto parse_err;
1767 if((line = impget_line()) == NULL) goto shortfile_err;
1770 /* get rate: and comp: lines for full dumps */
1772 rc = sscanf(line, "full-rate: %lf %lf %lf",
1773 &info.full.rate[0], &info.full.rate[1], &info.full.rate[2]);
1774 if(rc != 3) goto parse_err;
1777 if((line = impget_line()) == NULL) goto shortfile_err;
1778 rc = sscanf(line, "full-comp: %lf %lf %lf",
1779 &info.full.comp[0], &info.full.comp[1], &info.full.comp[2]);
1780 if(rc != 3) goto parse_err;
1782 /* get rate: and comp: lines for incr dumps */
1785 if((line = impget_line()) == NULL) goto shortfile_err;
1786 rc = sscanf(line, "incr-rate: %lf %lf %lf",
1787 &info.incr.rate[0], &info.incr.rate[1], &info.incr.rate[2]);
1788 if(rc != 3) goto parse_err;
1791 if((line = impget_line()) == NULL) goto shortfile_err;
1792 rc = sscanf(line, "incr-comp: %lf %lf %lf",
1793 &info.incr.comp[0], &info.incr.comp[1], &info.incr.comp[2]);
1794 if(rc != 3) goto parse_err;
1796 /* get stats for dump levels */
1800 if((line = impget_line()) == NULL) goto shortfile_err;
1801 if(strncmp_const(line, "//") == 0) {
1805 if(strncmp_const(line, "history:") == 0) {
1809 memset(&onestat, 0, SIZEOF(onestat));
1814 skip_whitespace(s, ch);
1815 if(ch == '\0' || strncmp_const_skip(s - 1, "stats:", s, ch) != 0) {
1819 skip_whitespace(s, ch);
1820 if(ch == '\0' || sscanf(s - 1, "%d", &level) != 1) {
1823 skip_integer(s, ch);
1825 skip_whitespace(s, ch);
1826 if(ch == '\0' || sscanf(s - 1, "%lld", &off_t_tmp) != 1) {
1829 onestat.size = (off_t)off_t_tmp;
1830 skip_integer(s, ch);
1832 skip_whitespace(s, ch);
1833 if(ch == '\0' || sscanf(s - 1, "%lld", &off_t_tmp) != 1) {
1836 onestat.csize = (off_t)off_t_tmp;
1837 skip_integer(s, ch);
1839 skip_whitespace(s, ch);
1840 if(ch == '\0' || sscanf(s - 1, "%lld", &time_t_tmp) != 1) {
1843 onestat.secs = (time_t)time_t_tmp;
1844 skip_integer(s, ch);
1846 skip_whitespace(s, ch);
1847 if(ch == '\0' || sscanf(s - 1, "%lld", &time_t_tmp) != 1) {
1850 /* time_t not guarranteed to be long */
1851 /*@i1@*/ onestat.date = (time_t)time_t_tmp;
1852 skip_integer(s, ch);
1854 skip_whitespace(s, ch);
1856 if(sscanf(s - 1, "%lld", &off_t_tmp) != 1) {
1859 onestat.filenum = (off_t)off_t_tmp;
1860 skip_integer(s, ch);
1862 skip_whitespace(s, ch);
1864 if (onestat.filenum != 0)
1866 onestat.label[0] = '\0';
1868 strncpy(onestat.label, s - 1, SIZEOF(onestat.label)-1);
1869 onestat.label[SIZEOF(onestat.label)-1] = '\0';
1873 if(level < 0 || level > 9) goto parse_err;
1875 info.inf[level] = onestat;
1878 for(i=0;i<=NB_HISTORY;i++) {
1879 info.history[i].level = -2;
1882 history_t onehistory;
1884 if(line[0] == '/' && line[1] == '/') {
1885 info.history[nb_history].level = -2;
1889 memset(&onehistory, 0, SIZEOF(onehistory));
1892 if(strncmp_const_skip(line, "history:", s, ch) != 0) {
1896 skip_whitespace(s, ch);
1897 if(ch == '\0' || sscanf((s - 1), "%d", &onehistory.level) != 1) {
1900 skip_integer(s, ch);
1902 skip_whitespace(s, ch);
1903 if(ch == '\0' || sscanf((s - 1), "%lld", &off_t_tmp) != 1) {
1906 onehistory.size = (off_t)off_t_tmp;
1907 skip_integer(s, ch);
1909 skip_whitespace(s, ch);
1910 if(ch == '\0' || sscanf((s - 1), "%lld", &off_t_tmp) != 1) {
1913 onehistory.csize = (off_t)off_t_tmp;
1914 skip_integer(s, ch);
1916 skip_whitespace(s, ch);
1917 if((ch == '\0') || sscanf((s - 1), "%lld", &time_t_tmp) != 1) {
1920 /* time_t not guarranteed to be long */
1921 /*@i1@*/ onehistory.date = (time_t)time_t_tmp;
1922 skip_integer(s, ch);
1924 info.history[nb_history++] = onehistory;
1926 if((line = impget_line()) == NULL) goto shortfile_err;
1928 /*@i@*/ amfree(line);
1930 /* got a full record, now write it out to the database */
1932 if(put_info(hostname, diskname, &info)) {
1933 g_fprintf(stderr, _("%s: error writing record for %s:%s\n"),
1934 get_pname(), hostname, diskname);
1941 /*@i@*/ amfree(line);
1944 g_fprintf(stderr, _("%s: parse error reading import record.\n"), get_pname());
1948 /*@i@*/ amfree(line);
1951 g_fprintf(stderr, _("%s: short file reading import record.\n"), get_pname());
1962 for(; (line = agets(stdin)) != NULL; free(line)) {
1966 skip_whitespace(s, ch);
1968 /* ignore comment lines */
1971 /* found non-blank, return line */
1974 /* otherwise, a blank line, so keep going */
1977 g_fprintf(stderr, _("%s: reading stdin: %s\n"),
1978 get_pname(), strerror(errno));
1983 /* ----------------------------------------------- */
1992 pp_scriptlist_t pp_scriptlist;
1997 g_printf("line %d:\n", dp->line);
1999 g_printf(" host %s:\n", hp->hostname);
2000 g_printf(" interface %s\n",
2001 interface_name(ip->config)[0] ? interface_name(ip->config) : "default");
2002 g_printf(" disk %s:\n", dp->name);
2003 if (dp->device) g_printf(" device %s\n", dp->device);
2005 g_printf(" program \"%s\"\n", dp->program);
2006 if (dp->application)
2007 g_printf(" application \"%s\"\n", application_name(dp->application));
2008 if (dp->exclude_file != NULL && dp->exclude_file->nb_element > 0) {
2009 g_printf(" exclude file");
2010 for(excl = dp->exclude_file->first; excl != NULL; excl = excl->next) {
2011 g_printf(" \"%s\"", excl->name);
2015 if (dp->exclude_list != NULL && dp->exclude_list->nb_element > 0) {
2016 g_printf(" exclude list");
2017 if(dp->exclude_optional) g_printf(" optional");
2018 for(excl = dp->exclude_list->first; excl != NULL; excl = excl->next) {
2019 g_printf(" \"%s\"", excl->name);
2023 if (dp->include_file != NULL && dp->include_file->nb_element > 0) {
2024 g_printf(" include file");
2025 for(excl = dp->include_file->first; excl != NULL; excl = excl->next) {
2026 g_printf(" \"%s\"", excl->name);
2030 if (dp->include_list != NULL && dp->include_list->nb_element > 0) {
2031 g_printf(" include list");
2032 if (dp->include_optional) g_printf(" optional");
2033 for(excl = dp->include_list->first; excl != NULL; excl = excl->next) {
2034 g_printf(" \"%s\"", excl->name);
2038 g_printf(" priority %d\n", dp->priority);
2039 g_printf(" dumpcycle %d\n", dp->dumpcycle);
2040 g_printf(" maxdumps %d\n", dp->maxdumps);
2041 g_printf(" maxpromoteday %d\n", dp->maxpromoteday);
2042 if (dp->bumppercent > 0) {
2043 g_printf(" bumppercent %d\n", dp->bumppercent);
2046 g_printf(" bumpsize %lld\n",
2047 (long long)dp->bumpsize);
2049 g_printf(" bumpdays %d\n", dp->bumpdays);
2050 g_printf(" bumpmult %lf\n", dp->bumpmult);
2052 g_printf(" strategy ");
2053 switch(dp->strategy) {
2058 g_printf("STANDARD\n");
2061 g_printf("NOFULL\n");
2064 g_printf("NOINC\n");
2067 g_printf("HANOI\n");
2070 g_printf("INCRONLY\n");
2073 g_printf(" ignore %s\n", (dp->ignore? "YES" : "NO"));
2074 g_printf(" estimate ");
2075 switch(dp->estimate) {
2077 g_printf("CLIENT\n");
2080 g_printf("SERVER\n");
2083 g_printf("CALCSIZE\n");
2087 g_printf(" compress ");
2088 switch(dp->compress) {
2093 g_printf("CLIENT FAST\n");
2096 g_printf("CLIENT BEST\n");
2098 case COMP_SERVER_FAST:
2099 g_printf("SERVER FAST\n");
2101 case COMP_SERVER_BEST:
2102 g_printf("SERVER BEST\n");
2105 if(dp->compress != COMP_NONE) {
2106 g_printf(" comprate %.2lf %.2lf\n",
2107 dp->comprate[0], dp->comprate[1]);
2110 g_printf(" encrypt ");
2111 switch(dp->encrypt) {
2116 g_printf("CLIENT\n");
2118 case ENCRYPT_SERV_CUST:
2119 g_printf("SERVER\n");
2123 g_printf(" auth %s\n", dp->security_driver);
2124 g_printf(" kencrypt %s\n", (dp->kencrypt? "YES" : "NO"));
2125 g_printf(" amandad_path %s\n", dp->amandad_path);
2126 g_printf(" client_username %s\n", dp->client_username);
2127 g_printf(" ssh_keys %s\n", dp->ssh_keys);
2129 g_printf(" holdingdisk ");
2130 switch(dp->to_holdingdisk) {
2132 g_printf("NEVER\n");
2138 g_printf("REQUIRED\n");
2142 g_printf(" record %s\n", (dp->record? "YES" : "NO"));
2143 g_printf(" index %s\n", (dp->index? "YES" : "NO"));
2144 g_printf(" starttime %04d\n", (int)dp->starttime);
2145 if(dp->tape_splitsize > (off_t)0) {
2146 g_printf(" tape_splitsize %lld\n",
2147 (long long)dp->tape_splitsize);
2149 if(dp->split_diskbuffer) {
2150 g_printf(" split_diskbuffer %s\n", dp->split_diskbuffer);
2152 if(dp->fallback_splitsize > (off_t)0) {
2153 g_printf(" fallback_splitsize %lldMb\n",
2154 (long long)(dp->fallback_splitsize / (off_t)1024));
2156 g_printf(" skip-incr %s\n", (dp->skip_incr? "YES" : "NO"));
2157 g_printf(" skip-full %s\n", (dp->skip_full? "YES" : "NO"));
2158 g_printf(" spindle %d\n", dp->spindle);
2159 pp_scriptlist = dp->pp_scriptlist;
2160 while (pp_scriptlist != NULL) {
2161 g_printf(" script \"%s\"\n", (pp_script_name(pp_scriptlist->data)));
2162 pp_scriptlist = pp_scriptlist->next;
2169 dtype = lookup_dumptype(dp->dtype_name);
2170 prop = val_t_display_strs(dumptype_getconf((dtype), DUMPTYPE_PROPERTY),
2172 for(p1 = prop; *p1 != NULL; p1++) {
2173 g_printf(" property %s\n", *p1);
2190 diskloop(argc, argv, "disklist", disklist_one);
2192 for(dp = diskq.head; dp != NULL; dp = dp->next)
2203 (void)argc; /* Quiet unused parameter warning */
2204 (void)argv; /* Quiet unused parameter warning */
2206 for(i = 0; version_info[i] != NULL; i++)
2207 g_printf("%s", version_info[i]);
2212 int argc G_GNUC_UNUSED,
2213 char **argv G_GNUC_UNUSED)
2215 dump_configuration();