From 92e15e22ea5cd563b31dde856abff4033f382976 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Fri, 13 Feb 2004 22:04:59 +0000 Subject: [PATCH] Misc git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1053 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/ReleaseNotes | 4 + bacula/kernstodo | 4 + bacula/src/stored/bcopy.c | 26 ++- bacula/src/stored/block.c | 4 +- bacula/src/stored/bls.c | 2 +- bacula/src/stored/btape.c | 10 +- bacula/src/stored/dev.c | 7 +- bacula/src/stored/read_record.c | 17 +- bacula/updatedb/README | 9 + bacula/updatedb/update_mysql_tables_6_to_7 | 67 ++++++ bacula/updatedb/update_sqlite_tables_6_to_7 | 217 ++++++++++++++++++++ 11 files changed, 343 insertions(+), 24 deletions(-) create mode 100644 bacula/updatedb/README create mode 100755 bacula/updatedb/update_mysql_tables_6_to_7 create mode 100755 bacula/updatedb/update_sqlite_tables_6_to_7 diff --git a/bacula/ReleaseNotes b/bacula/ReleaseNotes index dd83a03d06..db8232ac13 100644 --- a/bacula/ReleaseNotes +++ b/bacula/ReleaseNotes @@ -100,6 +100,10 @@ Items to note: !!!!! update your database with: ./update_bacula_tables + + Please save your old database before dropping the tables or doing + an upgrade or you may regret it later. + - smtp has now become bsmtp - console has now become bconsole. - console.conf is now bconsole.conf diff --git a/bacula/kernstodo b/bacula/kernstodo index 18acd46249..b7eab57d36 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -72,6 +72,10 @@ For 1.33 Testing/Documentation: http://howtos.linux.com/guides/nag2/x-087-2-nfs.mountd.shtml For 1.33 +- Make two tape fill test work. +- Check if the tape has moved before writing. +- Save and restore last_job across executions. +- Implement restart of daemon. - Handling removable disks -- see below: - Multiple drive autochanger support -- see below. - Keep track of tape use time, and report when cleaning is necessary. diff --git a/bacula/src/stored/bcopy.c b/bacula/src/stored/bcopy.c index 94b544bd38..761a7d2d7f 100644 --- a/bacula/src/stored/bcopy.c +++ b/bacula/src/stored/bcopy.c @@ -58,9 +58,10 @@ static void usage() " -b bootstrap specify a bootstrap file\n" " -c specify configuration file\n" " -d set debug level to nn\n" -" -v verbose\n" " -i specify input Volume names (separated by |)\n" " -o specify output Volume names (separated by |)\n" +" -p proceed inspite of errors\n" +" -v verbose\n" " -w specify working directory (default /tmp)\n" " -? print this message\n\n")); exit(1); @@ -71,11 +72,12 @@ int main (int argc, char *argv[]) int ch; char *iVolumeName = NULL; char *oVolumeName = NULL; + bool ignore_label_errors = false; - my_name_is(argc, argv, "bscan"); + my_name_is(argc, argv, "bcopy"); init_msg(NULL, NULL); - while ((ch = getopt(argc, argv, "b:c:d:mn:p:rsu:vV:w:?")) != -1) { + while ((ch = getopt(argc, argv, "b:c:d:i:o:pvw:?")) != -1) { switch (ch) { case 'b': bsr = parse_bsr(NULL, optarg); @@ -94,10 +96,6 @@ int main (int argc, char *argv[]) debug_level = 1; break; - case 'v': - verbose++; - break; - case 'i': /* input Volume name */ iVolumeName = optarg; break; @@ -106,6 +104,13 @@ int main (int argc, char *argv[]) oVolumeName = optarg; break; + case 'p': + ignore_label_errors = true; + break; + + case 'v': + verbose++; + break; case 'w': wd = optarg; @@ -135,6 +140,7 @@ int main (int argc, char *argv[]) /* Setup and acquire input device for reading */ in_jcr = setup_jcr("bcopy", argv[0], bsr, iVolumeName); + in_jcr->ignore_label_errors = ignore_label_errors; in_dev = setup_to_access_device(in_jcr, 1); /* read device */ if (!in_dev) { exit(1); @@ -178,7 +184,9 @@ int main (int argc, char *argv[]) } - +/* + * read_records() calls back here for each record it gets + */ static int record_cb(JCR *in_jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec) { if (list_records) { @@ -263,7 +271,7 @@ int dir_send_job_status(JCR *jcr) {return 1;} int dir_ask_sysop_to_mount_volume(JCR *jcr, DEVICE *dev) { - fprintf(stderr, "Mount Volume %s on device %s and press return when ready: ", + fprintf(stderr, "Mount Volume \"%s\" on device \"%s\" and press return when ready: ", in_jcr->VolumeName, dev_name(dev)); getchar(); return 1; diff --git a/bacula/src/stored/block.c b/bacula/src/stored/block.c index 58fa67ef5e..782e9d8862 100644 --- a/bacula/src/stored/block.c +++ b/bacula/src/stored/block.c @@ -650,8 +650,8 @@ reread: Dmsg1(90, "Read device got: ERR=%s\n", strerror(errno)); clrerror_dev(dev, -1); block->read_len = 0; - Mmsg2(&dev->errmsg, _("Read error on device %s. ERR=%s.\n"), - dev->dev_name, strerror(dev->dev_errno)); + Mmsg4(&dev->errmsg, _("Read error at file:block %d:%d on device %s. ERR=%s.\n"), + dev->file, dev->block_num, dev->dev_name, strerror(dev->dev_errno)); Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg); if (dev->state & ST_EOF) { /* EOF just seen? */ dev->state |= ST_EOT; /* yes, error => EOT */ diff --git a/bacula/src/stored/bls.c b/bacula/src/stored/bls.c index 1e01be67c2..ae24ab2b88 100644 --- a/bacula/src/stored/bls.c +++ b/bacula/src/stored/bls.c @@ -98,7 +98,7 @@ int main (int argc, char *argv[]) memset(&ff, 0, sizeof(ff)); init_include_exclude_files(&ff); - while ((ch = getopt(argc, argv, "b:c:d:e:i:jkLvV:?")) != -1) { + while ((ch = getopt(argc, argv, "b:c:d:e:i:jkLpvV:?")) != -1) { switch (ch) { case 'b': bsrName = optarg; diff --git a/bacula/src/stored/btape.c b/bacula/src/stored/btape.c index fcece7f4c9..3a4edca298 100644 --- a/bacula/src/stored/btape.c +++ b/bacula/src/stored/btape.c @@ -113,7 +113,7 @@ static DEV_BLOCK *this_block = NULL; static uint32_t last_file = 0; static uint32_t last_block_num = 0; static uint32_t BlockNumber = 0; -static int simple = FALSE; +static bool simple = true; static char *VolumeName = NULL; static int vol_num; @@ -1614,19 +1614,23 @@ blocks, it will stop. Then it will begin re-reading the\n\ two tapes.\n\n\ This may take a long time -- hours! ...\n\n"); +/* get_cmd("Insert a blank tape then indicate if you want\n" "to run the simplified test (s) with one tape or\n" "the complete multiple tape (m) test: (s/m) "); if (cmd[0] == 's') { Pmsg0(-1, "Simple test (single tape) selected.\n"); - simple = TRUE; + simple = true; } else if (cmd[0] == 'm') { Pmsg0(-1, "Complete multiple tape test selected.\n"); - simple = FALSE; + simple = false; } else { Pmsg0(000, "Command aborted.\n"); return; } +*/ + get_cmd("Insert a blank tape then indicate when you are ready ...\n"); + simple = true; set_volume_name("TestVolume1", 1); labelcmd(); diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index 8be58acc94..ece63bff7e 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -972,13 +972,14 @@ fsr_dev(DEVICE *dev, int num) stat = ioctl(dev->fd, MTIOCTOP, (char *)&mt_com); if (stat == 0) { dev->state &= ~ST_EOF; + dev->block_num += num; } else { if (dev->state & ST_EOF) { dev->state |= ST_EOT; } else { - dev->state |= ST_EOF; /* assume EOF */ - dev->file++; - dev->file_addr = 0; +// dev->state |= ST_EOF; /* assume EOF */ +// dev->file++; +// dev->file_addr = 0; } clrerror_dev(dev, MTFSR); Mmsg2(&dev->errmsg, _("ioctl MTFSR error on %s. ERR=%s.\n"), diff --git a/bacula/src/stored/read_record.c b/bacula/src/stored/read_record.c index 277e5778a8..2421ac480b 100644 --- a/bacula/src/stored/read_record.c +++ b/bacula/src/stored/read_record.c @@ -105,11 +105,16 @@ int read_records(JCR *jcr, DEVICE *dev, dev->file, dev_name(dev), jcr->VolumeName); continue; } else if (dev_state(dev, ST_SHORT)) { - Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg); + Jmsg1(jcr, M_ERROR, 0, "%s", dev->errmsg); continue; } else { /* I/O error or strange end of tape */ display_tape_error_status(jcr, dev); + if (jcr->ignore_label_errors) { + fsr_dev(dev, 1); /* try skipping bad record */ + Dmsg0(000, "Did fsr\n"); + continue; /* try to continue */ + } ok = FALSE; break; } @@ -344,19 +349,19 @@ static char *rec_state_to_str(DEV_RECORD *rec) static char buf[200]; buf[0] = 0; if (rec->state & REC_NO_HEADER) { - strcat(buf, "Nohdr,"); + bstrncat(buf, "Nohdr,", sizeof(buf)); } if (is_partial_record(rec)) { - strcat(buf, "partial,"); + bstrncat(buf, "partial,", sizeof(buf)); } if (rec->state & REC_BLOCK_EMPTY) { - strcat(buf, "empty,"); + bstrncat(buf, "empty,", sizeof(buf)); } if (rec->state & REC_NO_MATCH) { - strcat(buf, "Nomatch,"); + bstrncat(buf, "Nomatch,", sizeof(buf)); } if (rec->state & REC_CONTINUATION) { - strcat(buf, "cont,"); + bstrncat(buf, "cont,", sizeof(buf)); } if (buf[0]) { buf[strlen(buf)-1] = 0; diff --git a/bacula/updatedb/README b/bacula/updatedb/README new file mode 100644 index 0000000000..51fd358663 --- /dev/null +++ b/bacula/updatedb/README @@ -0,0 +1,9 @@ +updatedb scripts +13 Feb 2004 + +These scripts may be used to update older versions of bacula +databases. The scripts are designed using the standard install +locations for mysql, sqlite and the bacula working directory +as configured in the rpm builds. If you have different locations +you will need to edit the $bindir variable and the working +directory location before running them. diff --git a/bacula/updatedb/update_mysql_tables_6_to_7 b/bacula/updatedb/update_mysql_tables_6_to_7 new file mode 100755 index 0000000000..9eacdb0696 --- /dev/null +++ b/bacula/updatedb/update_mysql_tables_6_to_7 @@ -0,0 +1,67 @@ +#!/bin/sh +# +# Shell script to update MySQL tables from version 1.32 to 1.33 +# +echo " " +echo "This script will update a bacula database from version 6 to 7." +echo "Depending on the size of your database," +echo "this script may take several minutes to run." +echo " " + +# the location of the mysql program +bindir=/usr/bin + +if $bindir/mysql $* -f <