]> git.sur5r.net Git - bacula/docs/blobdiff - docs/manuals/en/concepts/newfeatures.tex
Update
[bacula/docs] / docs / manuals / en / concepts / newfeatures.tex
index 0ae82a460c8baa1727a3df74f1eb21d256a657e8..d6893eccb83a02a4cfe21dac956f1367fcdf3e72 100644 (file)
@@ -19,6 +19,7 @@ then the file will be backed up.  This does not, however, permit tracking what
 files have been deleted and will miss any file with an old time that may have
 been restored or moved on the client filesystem.
 
+\subsection{Accurate = \lt{}yes|no\gt{}}
 If the {\bf Accurate = \lt{}yes|no\gt{}} directive is enabled (default no) in
 the Job resource, the job will be run as an Accurate Job. For a {\bf Full}
 backup, there is no difference, but for {\bf Differential} and {\bf
@@ -145,6 +146,9 @@ run job=MyBackup level=VirtualFull
 And it would produce a new Full backup without using the client, and the output
 would be written to the {\bf Full} Pool which uses the Diskchanger Storage.
 
+If the Virtual Full is run, and there are no prior Jobs, the Virtual Full will
+fail with an error.
+
 \section{Duplicate Job Control}
 \index[general]{Duplicate Jobs}
 The new version of Bacula provides four new directives that
@@ -159,27 +163,26 @@ are specified in the Job resource.
 
 They are:
 
-\begin{description}
-\item [Allow Duplicate Jobs = \lt{}yes|no\gt{}]
+\subsection{Allow Duplicate Jobs = \lt{}yes|no\gt{}}
   If this directive is enabled duplicate jobs will be run.  If
   the directive is set to {\bf no} (default) then only one job of a given name
   may run at one time, and the action that Bacula takes to ensure only
   one job runs is determined by the other directives (see below).
 
-\item [Allow Higher Duplicates = \lt{}yes|no\gt{}]
+\subsection{Allow Higher Duplicates = \lt{}yes|no\gt{}}
   If this directive is set to {\bf yes} (default) the job with a higher
   priority (lower priority number) will be permitted to run.  If the
   priorities of the two jobs are the same, the outcome is determined by
   other directives (see below).
 
-\item [Cancel Queued Duplicates = \lt{}yes|no\gt{}]
+\subsection{Cancel Queued Duplicates = \lt{}yes|no\gt{}}
   If this directive is set to {\bf yes} (default) any job that is
   already queued to run but not yet running will be canceled.
 
-\item [Cancel Running Duplicates = \lt{}yes|no\gt{}]
+\subsection{Cancel Running Duplicates = \lt{}yes|no\gt{}}
   If this directive is set to {\bf yes} any job that is already running
   will be canceled.  The default is {\bf no}.
-\end{description}
+
 
 \section{TLS Authentication}
 \index[general]{TLS Authentication}
@@ -194,6 +197,7 @@ specify all the TLS directives normally used to enable communications
 encryption (TLS Enable, TLS Verify Peer, TLS Certificate, ...) and
 a new directive:
 
+\subsection{TLS Authenticate = yes}
 \begin{verbatim}
 TLS Authenticate = yes
 \end{verbatim}
@@ -223,7 +227,7 @@ updated only when Bacula terminated, thus if the daemon crashed, the
 state file might not contain all the run data.  This version of
 the Bacula daemons updates the state file on each job termination.
 
-\section{MaxFullInterval}
+\section{MaxFullInterval = \lt{}time-interval\gt{}}
 \index[general]{MaxFullInterval}
 The new Job resource directive {\bf Max Full Interval = \lt{}time-interval\gt{}}
 can be used to specify the maximum time interval between {\bf Full} backup
@@ -232,7 +236,7 @@ greater than the specified interval, and the job would normally be an
 {\bf Incremental} or {\bf Differential}, it will be automatically
 upgraded to a {\bf Full} backup.
 
-\section{MaxDiffInterval}
+\section{MaxDiffInterval = \lt{}time-interval\gt{}}
 \index[general]{MaxDiffInterval}
 The new Job resource directive {\bf Max Diff Interval = \lt{}time-interval\gt{}}
 can be used to specify the maximum time interval between {\bf Differential} backup
@@ -241,7 +245,7 @@ greater than the specified interval, and the job would normally be an
 {\bf Incremental}, it will be automatically
 upgraded to a {\bf Differential} backup.
 
-\section{No Dump Flag}
+\section{Honor No Dump Flag = \lt{}yes|no\gt{}}
 \index[general]{MaxDiffInterval}
 On FreeBSD systems, each file has a {\bf no dump flag} that can be set
 by the user, and when it is set it is an indication to backup programs
@@ -256,7 +260,7 @@ obey this flag.  The new directive is:
 The default value is {\bf no}.
 
 
-\section{Ignore Dir}
+\section{Ignore Dir = \lt{}filename-string\gt{}}
 \index[general]{IgnoreDir}
 The {\bf Ignore Dir = \lt{}filename\gt{}} is a new directive that can be added to the Include
 section of the FileSet resource.  If the specified
@@ -343,7 +347,7 @@ do by permitting users running restricted consoles to specify a
 definition. Without this directive restricted consoles may not modify
 the Plugin Options.
 
-\subsection{Plugin}
+\subsection{Plugin = \lt{}plugin-command-string\gt{}}
 The {\bf Plugin} directive is specified in the Include section of
 a FileSet resource where you put your {\bf File = xxx} directives.
 For example:
@@ -441,8 +445,148 @@ By using different command lines to {\bf bpipe},
 you can backup any kind of data (ASCII or binary) depending
 on the program called.
 
-\section{libdbi framework}
+\section{Microsoft Exchange Server 2003/2007 Plugin}
+
+\subsection{Concepts}
+
+Microsoft Exchange organises its storage into Storage Groups with
+Databases inside them. A default installation of Exchange will have a
+single Storage Group called 'First Storage Group', with two Databases
+inside it, "Mailbox Store (SERVER NAME)" and 
+"Public Folder Store (SERVER NAME)", 
+which hold user email and public folders respectively.
+
+In the default configuration, Exchange logs everything that happens to
+log files, such that if you have a backup, and all the log files since,
+you can restore to the present time. Each Storage Group has its own set
+of log files and operates independently of any other Storage Groups. At
+the Storage Group level, the logging can be turned off by enabling a
+function called "Enable circular logging". At this time the Exchange
+plugin will not function if this option is enabled.
+
+The plugin allows backing up of entire storage groups, and the restoring
+of entire storage groups or individual databases. Backing up and
+restoring at the individual mailbox or email item is not supported but
+can be simulated by use of the Recovery Storage Group (see below).
+
+\subsection{Installing}
+
+The Exchange plugin requires a DLL that is shipped with Microsoft
+Exchanger Server called {\bf esebcli2.dll}. Assuming Exchange is installed
+correctly the Exchange plugin should find this automatically and run
+without any additional installation.
+
+If the DLL can not be found automatically it will need to be copied into
+the Bacula installation
+directory (eg C:\verb+\+Program Files\verb+\+Bacula\verb+\+bin). The Exchange API DLL is
+named esebcli2.dll and is found in C:\verb+\+Program Files\verb+\+Exchsrvr\verb+\+bin on a
+default Exchange installation.
+
+\subsection{Backup up}
+
+To back up an Exchange server the Fileset definition must contain at
+least 'Plugin = "exchange:/@EXCHANGE/Microsoft Information Store"' for
+the backup to work correctly. The 'exchange:' bit tells Bacula to look
+for the exchange plugin, the '@EXCHANGE' bit makes sure all the backed
+up files are prefixed with something that isn't going to share a name
+with something outside the plugin, and the 'Microsoft Information Store'
+bit is required also. It is also possible to add the name of a storage
+group to the 'Plugin =' line, eg 'Plugin =
+"exchange:/@EXCHANGE/Microsoft Information Store/First Storage Group"'
+if you want only a single storage group backed up.
+
+Additionally, you can suffix the 'Plugin =' directive with
+':notrunconfull' which will tell the plugin not to truncate the Exchange
+database at the end of a full backup.
+
+An Incremental or Differential backup will backup only the database logs
+for each Storage Group by inspecting the 'modified date' on each
+physical log file. Because of the way the Exchange API works, the last
+logfile backed up on each backup will always be backed up by the next
+Incremental or Differential backup too. This adds 5MB to each
+Incremental or Differential backup size but otherwise does not cause any
+problems.
+
+\subsection{Restoring}
+
+The restore operation is much the same as a normal Bacula restore, with
+the following provisos:
+
+\begin{itemize}
+\item  The 'Where' restore option must not be specified
+\item Each Database directory must be marked as a whole. You cannot just
+     select (say) the .edb file and not the others.
+\item If a Storage Group is restored, the directory of the Storage Group
+     must be marked too.
+\item  It is possible to restore only a subset of the available log files,
+     but they {\bf must} be contiguous. Exchange will fail to restore correctly
+     if a log file is missing from the sequence of log files
+\item Each database to be restored must be dismounted and marked as 'Can be
+    overwritten by restore'
+\item If an entire Storage Group is to be restored (eg all databases and
+   logs in the Storage Group), then it is best to manually delete the
+   database files from the server (eg C:\verb+\+Program Files\verb+\+Exchsrvr\verb+\+mdbdata\verb+\+*)
+   as Exchange can get confused by stray log files lying around.
+\end{itemize}
+
+\subsection{Restoring to the Recovery Storage Group}
+
+The concept of the Recovery Storage Group is well documented by
+Microsoft 
+\elink{http://support.microsoft.com/kb/824126}{http://support.microsoft.com/kb/824126}, 
+but to briefly summarise...
+
+Microsoft Exchange allows the creation of an additional Storage Group
+called the Recovery Storage Group, which is used to restore an older
+copy of a database (eg before a mailbox was deleted) into without
+messing with the current live data. This is required as the Standard and
+Small Business Server versions of Exchange can not ordinarily have more
+than one Storage Group.
+
+To create the Recovery Storage Group, drill down to the Server in
+Exchange System Manager, right click, and select 
+{\bf "New -> Recovery Storage Group..."}. Accept or change the file locations and click OK. On
+the Recovery Storage Group, right click and select 
+{\bf "Add Database to Recover..."} and select the database you will be restoring.
+
+In Bacula, select the Database and the log files, making sure to mark
+the Storage Group directory itself too. Once you have selected the files
+to back up, use the RegexWhere clause to remove the prefix of
+"/@EXCHANGE/Microsoft Information Store/\lt{}storage group name\gt{}/" and
+replace it with "/@EXCHANGE/Microsoft Information Store/Recovery Storage Group/". 
+Then run the restore.
+
+\subsection{Caveats}
+
+This plugin is still being developed, so you should consider it
+currently in BETA test, and thus use in a production environment
+should be done only after very careful testing.
+
+The "Enable Circular Logging" option cannot be enabled or the plugin
+will fail.
+
+Exchange insists that a successful Full backup must have taken place if
+an Incremental or Differential backup is desired, and the plugin will
+fail if this is not the case. If a restore is done, Exchange will
+require that a Full backup be done before an Incremental or Differential
+backup is done.
+
+The plugin will most likely not work well if another backup application
+(eg NTBACKUP) is backing up the Exchange database, especially if the
+other backup application is truncating the log files.
+
+The Exchange plugin has not been tested with the {\bf Accurate} option, so
+we recommend either carefully testing or that you avoid this option for
+the current time.
+
+The Exchange plugin is not called during processing the bconsole {\bf estimate} command,
+and so anything that would be backed up by the plugin will not be added
+to the estimate total that is displayed.
+
+
+\section{libdbi Framework}
 As a general guideline, Bacula has support for a few catalog database drivers
+(MySQL, PostgreSQL, SQLite)
 coded natively by the Bacula team.  With the libdbi implementation, which is a
 Bacula driver that uses libdbi to access the catalog, we have an open field to
 use many different kinds database engines following the needs of users.
@@ -540,9 +684,35 @@ catalog.
 
 \section{Miscellaneous}
 \index[general]{Misc New Features}
-\begin{description}
-\item [Virtual Tape Emulation]
 
+\subsection{Allow Mixed Priority = \lt{}yes|no\gt{}}
+   This directive is only implemented in version 2.5 and later.  When
+   set to {\bf yes} (default {\bf no}), this job may run even if lower
+   priority jobs are already running.  This means a high priority job
+   will not have to wait for other jobs to finish before starting.
+   The scheduler will only mix priorities when all running jobs have
+   this set to true.
+
+   Note that only higher priority jobs will start early.  Suppose the
+   director will allow two concurrent jobs, and that two jobs with
+   priority 10 are running, with two more in the queue.  If a job with
+   priority 5 is added to the queue, it will be run as soon as one of
+   the running jobs finishes.  However, new priority 10 jobs will not
+   be run until the priority 5 job has finished.
+
+\subsection{Bootstrap File Directive -- FileRegex}
+  {\bf FileRegex} is a new command that can be added to the bootstrap
+  (.bsr) file.  The value is a regular expression.  When specified, only
+  matching filenames will be restored.
+
+  During a restore, if all File records are pruned from the catalog
+  for a Job, normally Bacula can restore only all files saved. That
+  is there is no way using the catalog to select individual files.
+  With this new command, Bacula will ask if you want to specify a Regex
+  expression for extracting only a part of the full backup.
+
+
+\subsection{Virtual Tape Emulation}
 We now have a Virtual Tape emulator that allows us to run though 99.9\% of
 the tape code but actually reading and writing to a disk file. Used with the
 \textbf{disk-changer} script, you can now emulate an autochanger with 10 drives
@@ -550,7 +720,7 @@ and 700 slots. This feature is most useful in testing.  It is enabled
 by using {\bf Device Type = vtape} in the Storage daemon's Device
 directive. This feature is only implemented on Linux machines.
 
-\item [Bat Enhancements]
+\subsection{Bat Enhancements}
 Bat (the Bacula Administration Tool) GUI program has been significantly
 enhanced and stabilized. In particular, there are new table based status 
 commands; it can now be easily localized using Qt4 Linguist.
@@ -558,7 +728,7 @@ commands; it can now be easily localized using Qt4 Linguist.
 The Bat communications protocol has been significantly enhanced to improve
 GUI handling.
 
-\item [RunScript Enhancements]
+\subsection{RunScript Enhancements}
 The {\bf RunScript} resource has been enhanced to permit multiple
 commands per RunScript.  Simply specify multiple {\bf Command} directives
 in your RunScript.
@@ -585,15 +755,15 @@ carefully tested and debugged and is known to easily crash the Director.
 We would appreciate feedback.  Due to the recursive nature of this command, we
 may remove it before the final release.
 
-\item [Status Enhancements]
+\subsection{Status Enhancements}
 The bconsole {\bf status dir} output has been enhanced to indicate
 Storage daemon job spooling and despooling activity.
 
-\item [Connect Timeout]
+\subsection{Connect Timeout}
 The default connect timeout to the File
 daemon has been set to 3 minutes. Previously it was 30 minutes.
 
-\item [ftruncate for NFS Volumes]
+\subsection{ftruncate for NFS Volumes}
 If you write to a Volume mounted by NFS (say on a local file server),
 in previous Bacula versions, when the Volume was recycled, it was not
 properly truncated because NFS does not implement ftruncate (file 
@@ -601,13 +771,13 @@ truncate). This is now corrected in the new version because we have
 written code (actually a kind user) that deletes and recreates the Volume,
 thus accomplishing the same thing as a truncate.
 
-\item [Support for Ubuntu]
+\subsection{Support for Ubuntu}
 The new version of Bacula now recognizes the Ubuntu (and Kubuntu)
 version of Linux, and thus now provides correct autostart routines.
 Since Ubuntu officially supports Bacula, you can also obtain any
 recent release of Bacula from the Ubuntu repositories.
 
-\item[Recycling enhancements]
+\subsection{Recycle Pool = \lt{}pool-name\gt{}}
 The new \textbf{RecyclePool} directive defines to which pool the Volume will
 be placed (moved) when it is recycled. Without this directive, a Volume will
 remain in the same pool when it is recycled. With this directive, it can be
@@ -615,18 +785,19 @@ moved automatically to any existing pool during a recycle. This directive is
 probably most useful when defined in the Scratch pool, so that volumes will
 be recycled back into the Scratch pool.
 
-\item [FD Version]
+\subsection{FD Version}
 The File daemon to Director protocol now includes a version 
-number, which will help us in future versions automatically determine
+number, which although there is no visible change for users, 
+will help us in future versions automatically determine
 if a File daemon is not compatible.
 
-\item [Max Run Sched Time]
+\subsection{Max Run Sched Time = \lt{}time-period-in-seconds\gt{}}
 The time specifies the maximum allowed time that a job may run, counted from
 when the job was scheduled. This can be useful to prevent jobs from running
 during working hours. We can see it like \texttt{Max Start Delay + Max Run
   Time}.
 
-\item [Max Wait Time] 
+\subsection{Max Wait Time = \lt{}time-period-in-seconds\gt{}}
 
 Previous \textbf{MaxWaitTime} directives aren't working as expected, instead
 of checking the maximum allowed time that a job may block for a resource,
@@ -636,20 +807,20 @@ their job depending on the level. Now, they have to use
 \textbf{Incr/Diff/Full Max Run Time}.  \textbf{Incr/Diff/Full Max Wait Time}
 directives are now deprecated.
 
-\item [Incremental|Differential Max Wait Time = \lt{}time\gt{}] 
+\subsection{Incremental|Differential Max Wait Time = \lt{}time-period-in-seconds\gt{}} 
 Theses directives have been deprecated in favor of
 \texttt{Incremental|Differential Max Run Time}.
 
-\item [Max Run Time directives]
+\subsection{Max Run Time directives}
 Using \textbf{Full/Diff/Incr Max Run Time}, it's now possible to specify the
 maximum allowed time that a job can run depending on the level.
 
 \addcontentsline{lof}{figure}{Job time control directives}
 \includegraphics{\idir different_time.eps}
 
-\item [Statistics Enhancements]
+\subsection{Statistics Enhancements}
 If you (or probably your boss) want to have statistics on your backups to
-provide some \textit{Service Level Agreement} indicators, you could use few
+provide some \textit{Service Level Agreement} indicators, you could use few
 SQL queries on the Job table to report how many:
 
 \begin{itemize}
@@ -665,19 +836,19 @@ be able to use them.
 
 Now, you can use the \textbf{update stats [days=num]} console command to fill
 the JobStat table with new Job records. If you want to be sure to take in
-account only \textbi{good jobs}, ie if one of your important job has failed but
+account only \textbf{good jobs}, ie if one of your important job has failed but
 you have fixed the problem and restarted it on time, you probably want to
 delete the first \textit{bad} job record and keep only the successful one. For
 that simply let your staff do the job, and update JobStat table after two or
 three days depending on your organization using the \textbf{[days=num]} option.
 
-These statistics records aren't used for restore purpose, but mainly for
+These statistics records aren't used for restoring, but mainly for
 capacity planning, billings, etc.
 
-The Bweb interface provide a statistics module that can use this feature. You
+The Bweb interface provides a statistics module that can use this feature. You
 can also use tools like Talend or extract information by yourself.
 
-The \textbf{Statistics Retention = \lt{}time\gt{}} director directive defines
+The {\textbf Statistics Retention = \lt{}time\gt{}} director directive defines
 the length of time that Bacula will keep statistics job records in the Catalog
 database after the Job End time. (In \texttt{JobStat} table) When this time
 period expires, and if user runs \texttt{prune stats} command, Bacula will
@@ -698,11 +869,10 @@ Job {
 }
 \end{verbatim}
 
-\item [Spooling Enhancements]
+\subsection{SpoolSize = \lt{}size-specification-in-bytes\gt{}}
 A new job directive permits to specify the spool size per job. This is used
 in advanced job tunning. {\bf SpoolSize={\it bytes}}
 
-\end{description}
 
 \section{Building Bacula Plugins}
 There is currently one sample program {\bf example-plugin-fd.c} and
@@ -752,6 +922,48 @@ exported entry points, place it in the {\bf Plugins Directory}, which is defined
 starts, it will load all the plugins that end with {\bf -fd.so} (or {\bf -fd.dll}
 on Win32) found in that directory.
 
+\section{Normal vs Command Plugins}
+In general, there are two ways that plugins are called. The first way, 
+is when a particular event is detected in Bacula, it will transfer control
+to each plugin that is loaded in turn informing the plugin of the event. 
+This is very similar to how a {\bf RunScript} works, and the events are very similar.
+Once the plugin gets control, it can interact with Bacula by getting and
+setting Bacula variables.  In this way, it behaves much like a RunScript.
+Currently very few Bacula variables are defined, but they will be implemented
+as the need arrises, and it is very extensible.
+
+We plan to have plugins register to receive events that they normally would
+not receive, such as an event for each file examined for backup or restore.
+This feature is not yet implemented.
+
+The second type of plugin, which is more useful and fully implemented
+in the current version is what we call a command plugin.  As with all
+plugins, it gets notified of important events as noted above (details described below),
+but in addition, this kind of plugin can accept a command line, which
+is a:
+
+\begin{verbatim}
+   Plugin = <command-string>
+\end{verbatim}
+
+directive that is placed in the Include section of a FileSet and is very
+similar to the "File = " directive.  When this Plugin directive is encountered 
+by Bacula during backup, it passes the "command" part of the Plugin directive
+only to the plugin that is explicitly named in the first field of that command string.
+This allows that plugin to backup any file or files on the system that it wants. It can
+even create "virtual files" in the catalog that contain data to be restored but do
+not necessarily correspond to actual files on the filesystem.
+
+The important features of the command plugin entry points are:
+\begin{itemize}
+ \item It is triggered by a "Plugin =" directive in the FileSet
+ \item Only a single plugin is called that is named on the "Plugin =" directive.
+ \item The full command string after the "Plugin =" is passed to the plugin
+    so that it can be told what to backup/restore.
+\end{itemize}
+
+
+\section{Loading Plugins}
 Once the File daemon loads the plugins, it asks the OS for the
 two entry points (loadPlugin and unloadPlugin) then calls the
 {\bf loadPlugin} entry point (see below).
@@ -861,6 +1073,9 @@ typedef struct s_baculaFuncs {
        int type, time_t mtime, const char *fmt, ...);
    bRC (*DebugMessage)(bpContext *ctx, const char *file, int line,
        int level, const char *fmt, ...);
+   void *(*malloc)(bpContext *ctx, const char *file, int line,
+       size_t size);
+   void (*free)(bpContext *ctx, const char *file, int line, void *mem);
 } bFuncs;
 \end{verbatim}
 
@@ -1143,6 +1358,9 @@ was passed during the {\bf loadPlugin} call and get to a number of Bacula variab
 at a future time and as needs require).
 
 \subsection{startBackupFile(bpContext *ctx, struct save\_pkt *sp)}
+This entry point is called only if your plugin is a command plugin, and 
+it is called when Bacula encounters the "Plugin = " directive in
+the Include section of the FileSet.
 Called when beginning the backup of a file. Here Bacula provides you
 with a pointer to the {\bf save\_pkt} structure and you must fill in 
 this packet with the "attribute" data of the file.
@@ -1231,17 +1449,19 @@ to do a backup while processing the "Plugin = " directive are:
 
 
 \subsection{endBackupFile(bpContext *ctx)}
-Called at the end of backing up a file.  If the plugin's work
+Called at the end of backing up a file for a command plugin.  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 (not yet implemented).
 This is probably a good time to release any malloc()ed memory you used to
 pass back filenames.
 
 \subsection{startRestoreFile(bpContext *ctx, const char *cmd)}
-Not yet implemented.
+Called when the first record is read from the Volume that was 
+previously written by the command plugin.
 
 \subsection{createFile(bpContext *ctx, struct restore\_pkt *rp)}
-Called to create a file during a Restore job before restoring the data. 
+Called for a command plugin to create a file during a Restore job before 
+restoring the data. 
 This entry point is called before any I/O is done on the file.  After
 this call, Bacula will call pluginIO() to open the file for write.
 
@@ -1264,7 +1484,7 @@ This call must return one of the following values:
 };
 \end{verbatim}
 
-in the restore\pkt value {\bf create\_status}.  For a normal file,
+in the restore\_pkt value {\bf create\_status}.  For a normal file,
 unless there is an error, you must return {\bf CF\_EXTRACT}.
 
 \begin{verbatim}
@@ -1290,17 +1510,70 @@ struct restore_pkt {
 };
 \end{verbatim}
 
+Typical code to create a regular file would be the following:
+
+\begin{verbatim}
+   struct plugin_ctx *p_ctx = (struct plugin_ctx *)ctx->pContext;
+   time_t now = time(NULL);
+   sp->fname = p_ctx->fname;   /* set the full path/filename I want to create */
+   sp->type = FT_REG;
+   sp->statp.st_mode = 0700 | S_IFREG;
+   sp->statp.st_ctime = now;
+   sp->statp.st_mtime = now;
+   sp->statp.st_atime = now;
+   sp->statp.st_size = -1;
+   sp->statp.st_blksize = 4096;
+   sp->statp.st_blocks = 1;
+   return bRC_OK;
+\end{verbatim}
+
+This will create a virtual file.  If you are creating a file that actually 
+exists, you will most likely want to fill the statp packet using the
+stat() system call.
+
+Creating a directory is similar, but requires a few extra steps:
+
+\begin{verbatim}
+   struct plugin_ctx *p_ctx = (struct plugin_ctx *)ctx->pContext;
+   time_t now = time(NULL);
+   sp->fname = p_ctx->fname;   /* set the full path I want to create */
+   sp->link = xxx; where xxx is p_ctx->fname with a trailing forward slash
+   sp->type = FT_DIREND
+   sp->statp.st_mode = 0700 | S_IFDIR;
+   sp->statp.st_ctime = now;
+   sp->statp.st_mtime = now;
+   sp->statp.st_atime = now;
+   sp->statp.st_size = -1;
+   sp->statp.st_blksize = 4096;
+   sp->statp.st_blocks = 1;
+   return bRC_OK;
+\end{verbatim}
+
+The link field must be set with the full cononical path name, which always 
+ends with a forward slash.  If you do not terminate it with a forward slash,
+you will surely have problems later.
+
+As with the example that creates a file, if you are backing up a real
+directory, you will want to do an stat() on the directory.  
+
+Note, if you want the directory permissions and times to be correctly
+restored, you must create the directory {\bf after} all the file directories
+have been sent to Bacula. That allows the restore process to restore all the
+files in a directory using default directory options, then at the end, restore
+the directory permissions.  If you do it the other way around, each time you
+restore a file, the OS will modify the time values for the directory entry.
+
 \subsection{setFileAttributes(bpContext *ctx, struct restore\_pkt *rp)}
-This is call not yet implemented.
+This is call not yet implemented.  Called for a command plugin.
 
-See the definition of {\bf restre\pkt} in the above section.
+See the definition of {\bf restre\_pkt} in the above section.
 
 \subsection{endRestoreFile(bpContext *ctx)}
-Called when done restoring a file.
+Called when a command plugin is done restoring a file.
 
 \subsection{pluginIO(bpContext *ctx, struct io\_pkt *io)}
 Called to do the input (backup) or output (restore) of data from or to a
-file. These routines simulate the Unix read(), write(), open(), close(), 
+file for a command plugin. These routines simulate the Unix read(), write(), open(), close(), 
 and lseek() I/O calls, and the arguments are passed in the packet and
 the return values are also placed in the packet.  In addition for Win32
 systems the plugin must return two additional values (described below).
@@ -1394,4 +1667,3 @@ should return:
 \end{description}
 
 
-