minimum code from Bacula. The bc\_types.h file is required to ensure that
the data type defintions in arguments correspond to the Bacula core code.
+The return codes are defined as:
+\begin{verbatim}
+typedef enum {
+ bRC_OK = 0, /* OK */
+ bRC_Stop = 1, /* Stop calling other plugins */
+ bRC_Error = 2, /* Some kind of error */
+ bRC_More = 3, /* More files to backup */
+} bRC;
+\end{verbatim}
+
+
At a future point in time, we hope to make the Bacula libbac.a into a
shared object so that the plugin can use much more of Bacula's
infrastructure, but for this first cut, we have tried to minimize the
happens at the beginning of a Job. If 10 Jobs are running
simultaneously, there will be at least 10 instances of the
plugin.
-
+
The bpContext structure will be passed to the plugin, and
- during this call, if the plugin needs to have any private
+ during this call, if the plugin needs to have its private
working storage that is associated with the particular
instance of the plugin, it should create it from the heap
- (malloc the memory). The plugin then puts a pointer to
+ (malloc the memory) and store a pointer to
its private working storage in the {\bf pContext} variable.
\begin{verbatim}
\end{verbatim}
This context pointer will be passed as the first argument to all
- the entry points that Bacula can call within the plugin. Needless
+ the entry points that Bacula calls within the plugin. Needless
to say, the plugin should not change the bContext variable, which
is Bacula's private context pointer for this instance of this
plugin.
\subsection{freePlugin(bpContext *ctx)}
- This entry point is called when the
- this instance of the plugin is no longer needed (the Job is
- ending), and the plugin should release any memory it may
- have allocated for the pContext.
+This entry point is called when the
+this instance of the plugin is no longer needed (the Job is
+ending), and the plugin should release all memory it may
+have allocated for the pContext.
\subsection{getPluginValue(bpContext *ctx, pVariable var, void *value)}
Bacula will call this entry point to get
- a value from the plugin. This entry point is currently not called.
+a value from the plugin. This entry point is currently not called.
\subsection{setPluginValue(bpContext *ctx, pVariable var, void *value)}
- Bacula will call this entry point to set
- a value in the plugin. This entry point is currently not called.
+Bacula will call this entry point to set
+a value in the plugin. This entry point is currently not called.
\subsection{handlePluginEvent(bpContext *ctx, bEvent *event, void *value)}
- This entry point is called when Bacula
- encounters certain events. Bacula passes the pointer to an event
- structure (bEvent), which currently has one item, the eventType:
+This entry point is called when Bacula
+encounters certain events (discussed below). Bacula passes the pointer to an event
+structure (bEvent), which currently has one item, the eventType:
\begin{verbatim}
typedef struct s_bEvent {
Most of which are pretty explanatory.
\begin{description}
- \item [bEventJobStart] is called whenever a Job starts.
- \item [bEventJobEnd] is called whenever a Job ends.
- \item [bEventStartBackupJob] is called when a Backup Job begins.
- \item [bEventEndBackupJob] is called when a Backup Job ends.
- \item [bEventStartRestoreJob] is called when a Restore Job starts.
- \item [bEventEndRestoreJob] is called when a Restore Job ends.
- \item [bEventStartVerifyJob] is called when a Verify Job starts.
- \item [bEventEndVerifyJob] is called when a Verify Job ends.
- \item [bEventBackupCommand]
- \item [bEventRestoreCommand]
- \item [bEventLevel] is called when the level is set for a new Job.
- \item [bEventSince] is called whent the since time is set for a new Job.
+ \item [bEventJobStart] is called whenever a Job starts. The value
+ passed is a pointer to a string that contains: "Jobid=nnn
+ Job=job-name". Where nnn will be replaced by the JobId and job-name
+ will be replaced by the Job name. The variable is temporary so if you
+ need the values, you must copy them.
+ \item [bEventJobEnd] is called whenever a Job ends. No value is passed.
+ \item [bEventStartBackupJob] is called when a Backup Job begins. No value
+ is passed.
+ \item [bEventEndBackupJob] is called when a Backup Job ends. No value is
+ passed.
+ \item [bEventStartRestoreJob] is called when a Restore Job starts. No value
+ is passed.
+ \item [bEventEndRestoreJob] is called when a Restore Job ends. No value is
+ passed.
+ \item [bEventStartVerifyJob] is called when a Verify Job starts. No value
+ is passed.
+ \item [bEventEndVerifyJob] is called when a Verify Job ends. No value
+ is passed.
+ \item [bEventBackupCommand] is called prior to the bEventStartBackupJob and
+ the plugin is passed the command string (everything after the equal sign
+ in "Plugin =" as the value.
+ \item [bEventRestoreCommand] is called prior to the bEventStartRestoreJob and
+ the plugin is passed the command string (everything after the equal sign
+ in "Plugin =" as the value.
+ \item [bEventLevel] is called when the level is set for a new Job. The value
+ is a 32 bit integer stored in the void*, which represents the Job Level code.
+ \item [bEventSince] is called when the since time is set for a new Job. The
+ value is a time\_t time at which the last job was run.
\end{description}
\subsection{startBackupFile(bpContext *ctx, struct save\_pkt *sp)}
bool portable; /* set if data format is portable */
char *cmd; /* command */
};
-
\end{verbatim}
+The second argument is a pointer to the {\bf save\_pkt} structure for the file
+to be backed up. The plugin is responsible for filling in all the fields
+of the {\bf save\_pkt}. The values in the {\bf save\_pkt} are used to create a virtual file
+entry in the Bacula catalog database. The full path and filename should be
+unique on the system to avoid conflicts with real files. Example programs such
+as {\bf bpipe.c} show how to set these fields.
\subsection{endBackupFile(bpContext *ctx)}
-Called at the end of backing up a file.
+Called at the end of backing up a file. If the plugin's work
+is done, it should return bRC\_OK. If the plugin wishes to create another
+file and back it up, then it must return bRC\_More.
\subsection{startRestoreFile(bpContext *ctx, const char *cmd)}
-Called when beginning to restore a file.
-
-\begin{verbatim}
- struct restore_pkt {
- int32_t stream; /* attribute stream id */
- int32_t data_stream; /* id of data stream to follow */
- int32_t type; /* file type FT */
- int32_t file_index; /* file index */
- int32_t LinkFI; /* file index to data if hard link */
- uid_t uid; /* userid */
- struct stat statp; /* decoded stat packet */
- const char *attrEx; /* extended attributes if any */
- const char *ofname; /* output filename */
- const char *olname; /* output link name */
- const char *where; /* where */
- const char *RegexWhere; /* regex where */
- int replace; /* replace flag */
-};
-\end{verbatim}
+Not implemented.
\subsection{endRestoreFile(bpContext *ctx)}
\subsection{createFile(bpContext *ctx, struct restore\_pkt *rp)}
-Called to create a file before restoring the data.
+Called to create a file before restoring the data. The data in the
+restore\_pkt is passed to the plugin and is based on the data that was
+originally given by the plugin during the backup and the current user
+restore settings (e.g. where, RegexWhere, replace). This allows the
+plugin to first create a file (if necessary) so that the data can
+be transmitted to it. The next call to the plugin will be a
+pluginIO command with a request to open the file write-only.
\begin{verbatim}
\end{verbatim}
\subsection{setFileAttributes(bpContext *ctx, struct restore\_pkt *rp)}
+This is call not yet implemented.
+
\begin{verbatim}
-
struct restore_pkt {
int32_t stream; /* attribute stream id */
int32_t data_stream; /* id of data stream to follow */