Package esmska.persistence
Class BackupManager
- java.lang.Object
-
- esmska.persistence.BackupManager
-
public class BackupManager extends java.lang.ObjectManager for taking care of backups of user configuration files.
-
-
Constructor Summary
Constructors Constructor Description BackupManager(java.io.File backupRoot)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanbackupFiles(java.util.Collection<java.io.File> files, boolean overwrite)Back up selected files to backup directory.voidremoveOldBackups(int backupsPreserved)Clean backup directory from old backup subdirs.
-
-
-
Method Detail
-
backupFiles
public boolean backupFiles(java.util.Collection<java.io.File> files, boolean overwrite) throws java.io.IOExceptionBack 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.IOExceptionClean 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
-
-