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