From 458061b568c4451c7f1d2212879645b2625651fb Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Thu, 15 May 2003 08:38:17 +0000 Subject: [PATCH] Win32 BackupRead/Write, begin adding Base, Jmsg knows about console, autochanger handles missing cassette on read git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@510 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/kernstodo | 33 ++++++- bacula/src/dird/autoprune.c | 17 +++- bacula/src/dird/backup.c | 4 + bacula/src/dird/dird_conf.c | 1 + bacula/src/dird/ua_prune.c | 14 ++- bacula/src/dird/ua_run.c | 10 +- bacula/src/filed/job.c | 13 +-- bacula/src/findlib/bfile.c | 57 ++++++------ bacula/src/jcr.h | 3 +- bacula/src/lib/btime.c | 2 + bacula/src/lib/util.c | 2 + bacula/src/stored/acquire.c | 66 ++++++++------ bacula/src/stored/autochanger.c | 10 ++ bacula/src/stored/mount.c | 7 +- bacula/src/stored/protos.h | 157 ++++++++++++++++---------------- bacula/src/version.h | 4 +- 16 files changed, 235 insertions(+), 165 deletions(-) diff --git a/bacula/kernstodo b/bacula/kernstodo index f3ecc48bde..f1327c1685 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -1,5 +1,5 @@ Kern's ToDo List - 13 May 2003 + 14 May 2003 Documentation to do: (any release a little bit at a time) - Document running a test version. @@ -7,7 +7,6 @@ Documentation to do: (any release a little bit at a time) - Document static linking - Document problems with Verify and pruning. - Document how to use multiple databases. -- Add a section to the doc on Manual cycling of Volumes. - For FreeBSD typical /dev/nrsa0 and for mtx /dev/pass1 @@ -20,7 +19,32 @@ Testing to do: (painful) - Figure out how to use ssh or stunnel to protect Bacula communications. For 1.31 release: -- Check if Job/File retentions apply to multivolume jobs. +14-May-2003 14:41 undef-sd: RestoreFiles.2003-05-14_14.41.00 Warning: acquire.c:106 Volume name mismatch. Wanted TestVolume0005 got TestVolume0010 +14-May-2003 14:41 undef-sd: 3301 Issuing autochanger "loaded" command. +14-May-2003 14:41 undef-sd: 3302 Issuing autochanger "unload" command. +14-May-2003 14:42 undef-sd: 3303 Issuing autochanger "load slot 1" command. +14-May-2003 14:42 undef-sd: 3304 Autochanger "load slot 1" status is OK. +14-May-2003 14:42 undef-sd: RestoreFiles.2003-05-14_14.41.00 Warning: acquire.c:106 Volume name mismatch. Wanted TestVolume0005 got TestVolume0009 +14-May-2003 14:42 undef-sd: 3301 Issuing autochanger "loaded" command. +14-May-2003 14:42 undef-sd: RestoreFiles.2003-05-14_14.41.00 Warning: acquire.c:106 Volume name mismatch. Wanted TestVolume0005 got TestVolume0009 +14-May-2003 14:42 undef-sd: 3301 Issuing autochanger "loaded" command. +14-May-2003 14:42 undef-sd: RestoreFiles.2003-05-14_14.41.00 Warning: acquire.c:106 Volume name mismatch. Wanted TestVolume0005 got TestVolume0009 +14-May-2003 14:42 undef-sd: 3301 Issuing autochanger "loaded" command. +14-May-2003 14:42 undef-sd: RestoreFiles.2003-05-14_14.41.00 Warning: acquire.c:106 Volume name mismatch. Wanted TestVolume0005 got TestVolume0009 +14-May-2003 14:42 undef-sd: 3301 Issuing autochanger "loaded" command. +14-May-2003 14:42 undef-sd: RestoreFiles.2003-05-14_14.41.00 Fatal error: acquire.c:129 Too many errors trying to mount device "/dev/nrsa0". +14-May-2003 14:42 undef-dir: Bacula 1.31 (12May03): 14-May-2003 14:42 + +- Implement MTIOCERRSTAT on FreeBSD to clear tape error conditions. + +- BSD (probably) does not have strtoll() +- BSD does not have ioctl() MTEOM +- BSD defines a number of MT_xxx variables which conflict + with those defined by Bacula. + +- The following Re-read last block at EOT failed. ERR=block.c:523 Read zero bytes on device /dev/nrsa0. + undef-sd: block.c:523 Read zero bytes on device /dev/nrsa0. + apparently masks the standard EOM message. - Add Progress command that periodically reports the progress of a job or all jobs. - Implement "Reschedule OnError=yes interval=nnn times=xxx" @@ -40,7 +64,6 @@ For 1.31 release: xeon-fd: Could not stat c:/Documents and Settings/All Users/Application Data/Humc:\Documents and Settings\All User98_AIX.kbf: ERR=No such file or directory -- Implement argv/argk in place of sscanf in the daemon protocol. - Examine Bare Metal restore problem (a FD crash exists somewhere ...). - Test multiple simultaneous Volumes - Document FInclude ... @@ -784,3 +807,5 @@ Done: (see kernsdone for more) The number of files mismatch! Volume=1 Catalog=0 rufus-sd: Matou.2003-05-10_10.39.18 Error: askdir.c:155 NULL Volume name. This shouldn't happen!!! - Shell character expansion is failing occassionally. +- Add a section to the doc on Manual cycling of Volumes. +- Check if Job/File retentions apply to multivolume jobs. diff --git a/bacula/src/dird/autoprune.c b/bacula/src/dird/autoprune.c index bdc6142085..70cef3fe39 100644 --- a/bacula/src/dird/autoprune.c +++ b/bacula/src/dird/autoprune.c @@ -34,6 +34,12 @@ /* Forward referenced functions */ +/* + * The pruning code was written to be referenced by the + * User Agent (i.e. the console), so to properly access it and + * to ensure that the Job gets the proper output, we create + * a User Agent context. This is a sort of mini-kludge. + */ void create_ua_context(JCR *jcr, UAContext *ua) { memset(ua, 0, sizeof(UAContext)); @@ -55,8 +61,8 @@ void free_ua_context(UAContext *ua) } /* - * Auto Prune Jobs and Files - * Volumes are done separately + * Auto Prune Jobs and Files. This is called at the end of every + * Job. We do not prune volumes here. */ int do_autoprune(JCR *jcr) { @@ -94,7 +100,9 @@ int do_autoprune(JCR *jcr) } /* - * Prune all volumes in current Pool. + * Prune all volumes in current Pool. This is called from + * catreq.c when the Storage daemon is asking for another + * volume and no appendable volumes are available. * * Return 0: on error * number of Volumes Purged @@ -119,13 +127,14 @@ int prune_volumes(JCR *jcr) db_lock(jcr->db); + /* Get the Pool Record and a list of Media Id's in the Pool */ pr.PoolId = jcr->PoolId; if (!db_get_pool_record(jcr, jcr->db, &pr) || !db_get_media_ids(jcr, jcr->db, &num_ids, &ids)) { Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db)); goto bail_out; } - + /* Visit each Volume and Prune it */ for (i=0; idb, &mr)) { diff --git a/bacula/src/dird/backup.c b/bacula/src/dird/backup.c index 872b94c106..e506c1b3dd 100644 --- a/bacula/src/dird/backup.c +++ b/bacula/src/dird/backup.c @@ -216,6 +216,9 @@ int do_backup(JCR *jcr) * Send Level command to File daemon */ switch (jcr->JobLevel) { + case L_BASE: + bnet_fsend(fd, levelcmd, "base", " "); + break; case L_FULL: bnet_fsend(fd, levelcmd, "full", " "); break; @@ -347,6 +350,7 @@ static void backup_cleanup(JCR *jcr, int TermCode, char *since) bpipe = open_bpipe(fname, 0, "w"); fd = bpipe ? bpipe->wfd : NULL; } else { + /* ***FIXME*** handle BASE */ fd = fopen(fname, jcr->JobLevel==L_FULL?"w+":"a+"); } if (fd) { diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index 05e7e218c7..fcec481e25 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -322,6 +322,7 @@ struct s_res resources[] = { */ struct s_jl joblevels[] = { {"Full", L_FULL, JT_BACKUP}, + {"Base", L_BASE, JT_BACKUP}, {"Incremental", L_INCREMENTAL, JT_BACKUP}, {"Differential", L_DIFFERENTIAL, JT_BACKUP}, {"Since", L_SINCE, JT_BACKUP}, diff --git a/bacula/src/dird/ua_prune.c b/bacula/src/dird/ua_prune.c index 196cf3d408..fa93fafed5 100644 --- a/bacula/src/dird/ua_prune.c +++ b/bacula/src/dird/ua_prune.c @@ -489,6 +489,11 @@ int prune_volume(UAContext *ua, POOL_DBR *pr, MEDIA_DBR *mr) db_lock(ua->db); memset(&jr, 0, sizeof(jr)); memset(&del, 0, sizeof(del)); + + /* + * Find out how many Jobs remain on this Volume by + * counting the JobMedia records. + */ cnt.count = 0; Mmsg(&query, cnt_JobMedia, mr->MediaId); if (!db_sql_query(ua->db, query, count_handler, (void *)&cnt)) { @@ -512,9 +517,11 @@ int prune_volume(UAContext *ua, POOL_DBR *pr, MEDIA_DBR *mr) del.max_ids = MAX_DEL_LIST_LEN; } + /* + * Now get a list of JobIds for Jobs written to this Volume + * Could optimize here by adding JobTDate > (now - period). + */ del.JobId = (JobId_t *)malloc(sizeof(JobId_t) * del.max_ids); - - /* ***FIXME*** could make this do JobTDate check too */ Mmsg(&query, sel_JobMedia, mr->MediaId); if (!db_sql_query(ua->db, query, file_delete_handler, (void *)&del)) { if (ua->verbose) { @@ -524,12 +531,13 @@ int prune_volume(UAContext *ua, POOL_DBR *pr, MEDIA_DBR *mr) goto bail_out; } - /* Use Volume Retention to prune Jobs and Files */ + /* Use Volume Retention to prune Jobs and their Files */ period = mr->VolRetention; now = (utime_t)time(NULL); Dmsg3(200, "Now=%d period=%d now-period=%d\n", (int)now, (int)period, (int)(now-period)); + for (i=0; i < del.num_ids; i++) { jr.JobId = del.JobId[i]; if (!db_get_job_record(ua->jcr, ua->db, &jr)) { diff --git a/bacula/src/dird/ua_run.c b/bacula/src/dird/ua_run.c index 0c32983004..1e21b3a235 100644 --- a/bacula/src/dird/ua_run.c +++ b/bacula/src/dird/ua_run.c @@ -463,21 +463,25 @@ When: %s\n"), /* Level */ if (jcr->JobType == JT_BACKUP) { start_prompt(ua, _("Levels:\n")); + add_prompt(ua, _("Base")); add_prompt(ua, _("Full")); add_prompt(ua, _("Incremental")); add_prompt(ua, _("Differential")); add_prompt(ua, _("Since")); switch (do_prompt(ua, _("Select level"), NULL, 0)) { case 0: - jcr->JobLevel = L_FULL; + jcr->JobLevel = L_BASE; break; case 1: - jcr->JobLevel = L_INCREMENTAL; + jcr->JobLevel = L_FULL; break; case 2: - jcr->JobLevel = L_DIFFERENTIAL; + jcr->JobLevel = L_INCREMENTAL; break; case 3: + jcr->JobLevel = L_DIFFERENTIAL; + break; + case 4: jcr->JobLevel = L_SINCE; break; default: diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index 398feede19..173da924b8 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -405,10 +405,11 @@ static int level_cmd(JCR *jcr) free_memory(level); return 0; } - /* - * Full backup requested - */ - if (strcmp(level, "full") == 0) { + /* Base backup requested? */ + if (strcmp(level, "base") == 0) { + jcr->save_level = L_BASE; + /* Full backup requested? */ + } else if (strcmp(level, "full") == 0) { jcr->save_level = L_FULL; /* * Backup requested since