 +   /* Now find all the files that are missing -- i.e. all files in
 +    *  the database where the MarkId != current JobId
 +    */
++
 +   bsnprintf(buf, sizeof(buf),
-+      "SELECT Path.Path,Filename.Name FROM File,Path,Filename "
-+      "WHERE File.JobId=%d "
-+      "AND File.MarkId!=%d AND File.PathId=Path.PathId "
-+      "AND File.FilenameId=Filename.FilenameId",
-+         JobId, jcr->JobId);
++      "SELECT Path.Path,Filename.Name "
++        "FROM CurrentBackup "
++             "JOIN File USING (FileId) "
++             "JOIN Path USING (PathId) "
++             "JOIN Filename USING (FilenameId) "
++      "WHERE CurrentBackup.BackupId=%s "
++        "AND File.MarkId!=%d ",
++	     edit_uint64(backupid, ed1), edit_uint64(jcr->JobId, ed2));
 +   /* missing_handler is called for each file found */
 +   db_sql_query(jcr->db, buf, missing_handler, (void *)jcr);
 +

    free_pool_memory(jcr->acl_text);
 
    stop_heartbeat_monitor(jcr);
@@ -355,9 +447,11 @@
    case FT_DIRNOCHG:
    case FT_NOCHG:
       Jmsg(jcr, M_SKIPPED, 1, _("     Unchanged file skipped: %s\n"), ff_pkt->fname);

  * Find all the requested files and send them
  * to the Storage daemon.
  *
@@ -66,6 +141,7 @@
    BSOCK *sd;
    bool ok = true;
    // TODO landonf: Allow user to specify encryption algorithm
