]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
snapshot: Fix #9143 About snapshot not properly stored in the catalog
authorEric Bollengier <eric@baculasystems.com>
Wed, 18 May 2022 11:53:23 +0000 (13:53 +0200)
committerEric Bollengier <eric@baculasystems.com>
Fri, 27 May 2022 08:31:45 +0000 (10:31 +0200)
bacula/src/dird/catreq.c
bacula/src/dird/getmsg.c
bacula/src/dird/snapshot.c

index c5f3f48663807a96af8bf5dc8e7b767aff09600f..5f753114c3a8af2dda65c430953fbe9f1b5b191c 100644 (file)
@@ -121,9 +121,6 @@ static int send_volume_info_to_storage_daemon(JCR *jcr, BSOCK *sd, MEDIA_DBR *mr
    return stat;
 }
 
-/* TODO: See if we want to let the FD do all kind
- *       of catalog request/update
- */
 void catalog_request(JCR *jcr, BSOCK *bs)
 {
    MEDIA_DBR mr, sdmr;
index b2cf7c7b700b6494a59239dec04c80e08341af59..89e6b97785c883fe5b220579685653c201b1c4e3 100644 (file)
@@ -268,6 +268,11 @@ int bget_dirmsg(JCR *jcr, BSOCK *bs, BSOCK_CLIENT_TYPE role)
          catalog_request(jcr, bs);
          continue;
       }
+      /* Only the Snapshot commands are authorized for the FD */
+      if (role==BSOCK_TYPE_FD && bs->msg[0] == 'C') {
+         snapshot_catreq(jcr, bs);
+         continue;
+      }
       if (role==BSOCK_TYPE_SD && bs->msg[0] == 'U') {        /* SD sending attributes */
          Dmsg2(900, "Catalog upd jcr=%p: %s", jcr, bs->msg);
          catalog_update(jcr, bs);
index 14126ff241ebf761a8df6071bad47b1b822dfcef..39e6f58216d7e1c88cfcb38cb7837b7cd34e3650 100644 (file)
@@ -523,6 +523,11 @@ static int list_client_snapshot(UAContext *ua, bool sync)
 /* Ask client to create/prune/delete a snapshot via the command line */
 int snapshot_cmd(UAContext *ua, const char *cmd)
 {
+   if (!open_client_db(ua)) {
+      Dmsg0(10, "Unable to open database\n");
+      return 0;
+   }
+
    SNAPSHOT_DBR snapdbr;
    for (int i=0; i<ua->argc; i++) {
       if (strcasecmp(ua->argk[i], NT_("purge")) == 0) {