Keywords: developers

# Bacula FD Plugin API

To write a Bacula plugin, you create a dynamic shared object program (or dll on Win32) with a particular name and two exported entry points, place it in the Plugins Directory, which is defined in the bacula-fd.conf file in the Client resource, and when the FD starts, it will load all the plugins that end with -fd.so (or -fd.dll on Win32) found in that directory.

Subsections

- Normal vs Command vs Options Plugins
- Loading Plugins
- loadPlugin
- Plugin Entry Points
  - newPlugin(bpContext *ctx)
  - freePlugin(bpContext *ctx)
  - getPluginValue(bpContext *ctx, pVariable var, void *value)
  - setPluginValue(bpContext *ctx, pVariable var, void *value)
  - handlePluginEvent(bpContext *ctx, bEvent *event, void *value)
  - startBackupFile(bpContext *ctx, struct save_pkt *sp)
  - endBackupFile(bpContext *ctx)
  - startRestoreFile(bpContext *ctx, const char *cmd)
  - createFile(bpContext *ctx, struct restore_pkt *rp)
  - setFileAttributes(bpContext *ctx, struct restore_pkt *rp)
  - endRestoreFile(bpContext *ctx)
  - pluginIO(bpContext *ctx, struct io_pkt *io)
  - bool checkFile(bpContext *ctx, char *fname)
- Bacula Plugin Entrypoints
  - bRC registerBaculaEvents(bpContext *ctx, ...)
  - bRC getBaculaValue(bpContext *ctx, bVariable var, void *value)
  - bRC setBaculaValue(bpContext *ctx, bVariable var, void *value)
  - bRC JobMessage(bpContext *ctx, const char *file, int line, int type, utime_t mtime, const char *fmt, ...)
  - bRC DebugMessage(bpContext *ctx, const char *file, int line, int level, const char *fmt, ...)
  - void baculaMalloc(bpContext *ctx, const char *file, int line, size_t size)
  - void baculaFree(bpContext *ctx, const char *file, int line, void *mem)
- Building Bacula Plugins