001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the
004 * License.
005 *
006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
007 * specific language governing permission and limitations under the License.
008 *
009 * When distributing Covered Software, include this CDDL Header Notice in each file and include
010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
011 * Header, with the fields enclosed by brackets [] replaced by your own identifying
012 * information: "Portions Copyright [year] [name of copyright owner]".
013 *
014 * Copyright 2006-2008 Sun Microsystems, Inc.
015 * Portions copyright 2015 ForgeRock AS.
016 */
017package org.opends.server.types;
018
019/**
020 * This class defines a data structure for holding configuration
021 * information to use when performing a backup of a Directory Server
022 * backend.  This configuration may specify a full backup (in which
023 * the entire contents of the backend repository is to be archived),
024 * or incremental (in which only a small set of data containing
025 * changes since the last incremental or full backup need be
026 * preserved).  Note that some backends may not support incremental
027 * backups, and those that do may require that incremental backups use
028 * the same settings as the full backup with regard to compression,
029 * encryption, hashing, signing, etc.  Also note that if the
030 * incremental backups are supported, it must be possible to restore
031 * the original full backup or any individual incremental backup taken
032 * since that full backup (i.e., an incremental backup must not
033 * prevent restoring an earlier incremental backup or the original
034 * full backup with which the incremental backups are associated).
035 */
036@org.opends.server.types.PublicAPI(
037     stability=org.opends.server.types.StabilityLevel.VOLATILE,
038     mayInstantiate=true,
039     mayExtend=false,
040     mayInvoke=true)
041public final class BackupConfig extends OperationConfig
042{
043  /**
044   * The path to the directory in which the backup file(s) should be
045   * created.
046   */
047  private BackupDirectory backupDirectory;
048
049  /** Indicates whether the data should be compressed as it is written. */
050  private boolean compressData;
051
052  /** Indicates whether the data should be encrypted as it is written. */
053  private boolean encryptData;
054
055  /**
056   * Indicates whether to generate a cryptographic hash of the data as
057   * it is written.
058   */
059  private boolean hashData;
060
061  /** Indicates whether to attempt an incremental backup. */
062  private boolean isIncremental;
063
064  /**
065   * Indicates whether to digitally sign the hash when the backup is
066   * complete.
067   */
068  private boolean signHash;
069
070  /**
071   * The unique identifier assigned to this backup operation (which
072   * may be used to indicate which version to restore if multiple
073   * backups are in the same directory).
074   */
075  private String backupID;
076
077  /**
078   * The unique ID for the existing full or incremental backup against
079   * which the incremental backup should be based.
080   */
081  private String incrementalBaseID;
082
083
084  /**
085   * Creates a new backup configuration that will create a full or
086   * incremental backup of a backend using the provided information.
087   *
088   * @param  backupDirectory  The backup directory structure that
089   *                          indicates where the files should be
090   *                          written.
091   * @param  backupID         The unique identifier assigned to this
092   *                          backup.
093   * @param  isIncremental    Indicates whether this is to be an
094   *                          incremental or a full backup.
095   */
096  public BackupConfig(BackupDirectory backupDirectory,
097                      String backupID, boolean isIncremental)
098  {
099    this.backupDirectory = backupDirectory;
100    this.backupID        = backupID;
101    this.isIncremental   = isIncremental;
102  }
103
104
105
106  /**
107   * Retrieves the backup directory structure for this backup
108   * configuration.
109   *
110   * @return  The backup directory structure for this backup
111   *          configuration.
112   */
113  public BackupDirectory getBackupDirectory()
114  {
115    return backupDirectory;
116  }
117
118
119
120  /**
121   * Retrieves the identifier associated with this backup
122   * configuration, which can be used later to indicate which backup
123   * should be restored if multiple backups are stored in the same
124   * location.
125   *
126   * @return  The identifier associated with this backup
127   *          configuration.
128   */
129  public String getBackupID()
130  {
131    return backupID;
132  }
133
134
135
136  /**
137   * Indicates whether the backend should attempt to perform an
138   * incremental backup containing only the changes since the last
139   * incremental or full backup.
140   *
141   * @return  <CODE>true</CODE> if this should be an incremental
142   *          backup, or <CODE>false</CODE> if it should be a full
143   *          backup.
144   */
145  public boolean isIncremental()
146  {
147    return isIncremental;
148  }
149
150
151
152  /**
153   * Retrieves the backup ID for the backup on which this incremental
154   * backup should be based.  If it is <CODE>null</CODE>, then the
155   * backend is free to choose the appropriate existing backup on
156   * which to base this incremental backup.
157   *
158   * @return  The backup ID for the backup on which this incremental
159   *          backup should be based, or <CODE>null</CODE> if none was
160   *          specified.
161   */
162  public String getIncrementalBaseID()
163  {
164    return incrementalBaseID;
165  }
166
167
168
169  /**
170   * Specifies the backup ID for the backup on which this incremental
171   * backup should be based.
172   *
173   * @param  incrementalBaseID  The backup ID for the backup on which
174   *                            this incremental backup should be
175   *                            based.
176   */
177  public void setIncrementalBaseID(String incrementalBaseID)
178  {
179    this.incrementalBaseID = incrementalBaseID;
180  }
181
182
183
184  /**
185   * Indicates whether the backup process should compress the data as
186   * it is archived.
187   *
188   * @return  <CODE>true</CODE> if the backup process should compress
189   *          the data as it is archived, or <CODE>false</CODE> if
190   *          not.
191   */
192  public boolean compressData()
193  {
194    return compressData;
195  }
196
197
198
199  /**
200   * Specifies whether the backup process should compress the data as
201   * it is archived.
202   *
203   * @param  compressData  Specifies whether the backup process should
204   *                       compress the data as it is archived.
205   */
206  public void setCompressData(boolean compressData)
207  {
208    this.compressData = compressData;
209  }
210
211
212
213  /**
214   * Indicates whether the backup process should encrypt the data as
215   * it is archived.
216   *
217   * @return  <CODE>true</CODE> if the backup process should encrypt
218   *          the data as it is archived, or <CODE>false</CODE> if
219   *          not.
220   */
221  public boolean encryptData()
222  {
223    return encryptData;
224  }
225
226
227
228  /**
229   * Specifies whether the backup process should encrypt the data as
230   * it is archived.
231   *
232   * @param  encryptData  Specifies whether the backup process should
233   *                      encrypt the data as it is archived.
234   */
235  public void setEncryptData(boolean encryptData)
236  {
237    this.encryptData = encryptData;
238  }
239
240
241
242  /**
243   * Indicates whether the backup process should generate a hash of
244   * the data as it is archived that may be validated as part of the
245   * restore process.
246   *
247   * @return  <CODE>true</CODE> if the backup process should generate
248   *          a hash of the data as it is archived, or
249   *          <CODE>false</CODE> if not.
250   */
251  public boolean hashData()
252  {
253    return hashData;
254  }
255
256
257
258  /**
259   * Specifies whether the backup process should generate a hash of
260   * the data as it is archived.
261   *
262   * @param  hashData  Specifies whether the backup process should
263   *                   generate a hash of the data as it is archived.
264   */
265  public void setHashData(boolean hashData)
266  {
267    this.hashData = hashData;
268  }
269
270
271
272  /**
273   * Indicates whether the backup process should digitally sign the
274   * hash of the data when it is archived.  Signing the hash offers a
275   * means of protection against tampering by an unauthorized party.
276   * Note that this option is only applicable if the backup is to
277   * include a hash of the archived data.
278   *
279   * @return  <CODE>true</CODE> if the backup process should digitally
280   *          sign the generated hash, or <CODE>false</CODE> if not.
281   */
282  public boolean signHash()
283  {
284    return signHash;
285  }
286
287
288
289  /**
290   * Specifies whether the backup process should digitally sign the
291   * hash of the data when it is archived.
292   *
293   * @param  signHash  Specifies whether the backup process should
294   *                   digitally sign the data when it is archived.
295   */
296  public void setSignHash(boolean signHash)
297  {
298    this.signHash = signHash;
299  }
300}
301