private void cleanStaleFiles ( File backupDir , AsyncOperationStatus status ) { String [ ] filesInEnv = env . getHome ( ) . list ( ) ; String [ ] filesInBackupDir = backupDir . list ( ) ; if ( filesInEnv != null && filesInBackupDir != null ) { HashSet < String > envFileSet = new HashSet < String > ( ) ; for ( String file : filesInEnv ) envFileSet . ( file ) ; // delete all files in backup which are currently not in environment for ( String file : filesInBackupDir ) { if ( file . endsWith ( BDB_EXT ) && ! envFileSet . contains ( file ) ) { status . setStatus ( "Deleting stale jdb file :" + file ) ; File staleJdbFile = new File ( backupDir , file ) ; staleJdbFile . delete ( ) ; } } } }
For recovery from the latest consistent snapshot we should clean up the old files from the previous backup set else we will fill the disk with useless log files