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