
\section*{Migration}
\label{_MigrationChapter}
\index[general]{Migration} 
\addcontentsline{toc}{section}{Migration}

The term Migration as used in the context of Bacula means moving data from one
Volume to another, and in particular it is
a Job (similar to a backup job) that reads data that was previously
backed up to a Volume and writes it to another Volume purging the 
catalog records associated with the first backup job.  In other words,
Migration moves Bacula Job data from one Volume to another. Although we 
mention Volumes, in reality, Migration is based on moving individual Jobs from
one Pool to another. 

Migrations can be based on quite a number of different criteria such as:
a single previous Job; a Volume; a Client; a regular expression matching
a Job, Volume, or Client name; the time a Job is on a Volume; high 
and low water marks (usage or occupation) of a Pool; Volume size, ...
The details of these selection criteria will be defined below.


To run a Migration job, you must have defined a Job resource very similar
to a Backup Job but with {\bf Type = Migrate} instead of {\bf Type =
Backup}.  The migration job then starts much like a backup job starts and 
searches for a previous backup Job or Jobs that matches the parameters you have
specified in the migration Job resource (detailed a bit later). Then
for each previous backup Job found, the Migration Job will run a new
Job which copies the old Job data from the previous Volume to a new
Volume defined in the Migration Pool. It is possible that no prior
Jobs are found for migration, in which case, the Migration job will
simply terminate having done nothing, but normally at a minimum, three jobs 
are involved during a migration:

\begin{itemize}
\item The currently running Migration Job
\item The previous Backup Job
\item A new Backup Job that writes the previous data to
      the new Volume.
\end{itemize}

If the Migration is for a particular Volume, multiple new Backup Jobs
may be started, one for each Job on the Volume.



\subsection*{Migration Job Resource Directives}
\addcontentsline{toc}{section}{Migration Job Resource Directives}

The following directives can appear in a Director's Job resource, and they
are used to define a Migration job.          

\begin{description}
\item [Type = Migrate]
This defines the job that is run as being a Migration Job.
Migration Jobs do not have any Files associated with them, and in
that sense they are more or less like an Admin job. They just
check to see if there is anything to Migrate then possibly start
and control new Backup jobs to move the data.  
 
\item [Selection Type = \lt{}Selection-type-keyword\gt{}]  
  Where \lt{}Selection-type-keyword\gt{} can be:
  \begin{description}
  \item [SmallestVolume] This selection keyword selects the smallest volume in
        the Pool to be migrated.
  \item [OldestVolume] This selection keyword selects the oldest volume in
        the Pool to be migrated.
  \item [Client]
  \item [Volume]
  \item [Job]
  \item [SQLQuery]
  \item [PoolOccupancy] Not yet implemented.
  \item [PoolTime] Not yet implemented.
  \end{description}
\end{description}


\item [Selection Pattern = \lt{}Quoted-string\gt{}]
The Selection Patterns permitted for each Selection-type-keyword
are described above.

\end{description}

\subsection*{Migration Pool Resource Directives}
\addcontentsline{toc}{section}{Migration Pool Resource Directives}

The following directives can appear in a Director's Pool resource, and they
are used to define a Migration job.          

\begin{description}
\item [Migration Time = \lt{}time-specification\gt{}]
If a PoolTime migration is done, the time specified here in seconds (time
modifiers are permitted -- e.g. hours, ...) will be used. If the     
previous Backup Job or Jobs selected have been in the Pool longer than
the specified PoolTime, then they will be migrated.
 
\item [Migration High Bytes =  \lt{}byte-specification\gt{}]

\item [Migration Low Bytes = \lt{}byte-specification\gt{}]

\item [Next Pool = \lt{}pool-specification\gt{}]

\item [Storage = \lt{}storage-specification\gt{}]

\end{description}
