esmska.persistence
Class BackupManager

java.lang.Object
  extended by esmska.persistence.BackupManager

public class BackupManager
extends java.lang.Object

Manager for taking care of backups of user configuration files.


Constructor Summary
BackupManager(java.io.File backupRoot)
          Constructor.
 
Method Summary
 boolean backupFiles(java.util.Collection<java.io.File> files, boolean overwrite)
          Back up selected files to backup directory.
 void removeOldBackups(int backupsPreserved)
          Clean backup directory from old backup subdirs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BackupManager

public BackupManager(java.io.File backupRoot)
Constructor.

Parameters:
backupRoot - Directory under which the backups will be created and managed. Not null.
Method Detail

backupFiles

public boolean backupFiles(java.util.Collection<java.io.File> files,
                           boolean overwrite)
                    throws java.io.IOException
Back up selected files to backup directory. A new subdirectory in a format of yyyy-mm-dd will be created for them.

Parameters:
files - files to back up. Not null. Non-existent files are ignored.
overwrite - if backup should overwrite already existing subdirectory (i.e. backup from today)
Returns:
true if files were backed up; false if they weren't (e.g. backup already existed and wasn't overwritten)
Throws:
java.io.IOException

removeOldBackups

public void removeOldBackups(int backupsPreserved)
                      throws java.io.IOException
Clean backup directory from old backup subdirs.

Parameters:
backupsPreserved - how many old backups should be preserved. All other (older) backups will be deleted. Negative integer is converted to 0.
Throws:
java.io.IOException