Subject Re: [Firebird-Java] FBNBackupManager issue
Author
Hello Thomas
Here is the code.
To deliberately raise error when restore I add N=0 file and twice N=1 file.

//---------BACKUP
FBNBackupManager fBBackupManager = new FBNBackupManager(GDSType.getType("PURE_JAVA"));
fBBackupManager.setDatabase(dbPath);
fBBackupManager.setUser(DbPath.getDbUser());
fBBackupManager.setPassword(DbPath.getDbPass());
fBBackupManager.setHost(DbPath.getDbHost());
fBBackupManager.setPort(DbPath.getPort());
String lvlStr = Config.getStringValue(Config.NBACKUP_PARAM);
lvl = 0;
if (lvlStr != null)
    lvl = Integer.parseInt(lvlStr.substring(1, 5));
lvl+=shouldIncrementN();
fBBackupManager.setBackupLevel(lvl);
fBBackupManager.setBackupFile(backup.getAbsoluteFile().toString());
try {
        ckupManager.backupDatabase();
    } catch (SQLException e) {
        e.printStackTrace();
        return;
}

//----------RESTORE-------------
        FBNBackupManager fBBackupManager = new FBNBackupManager(org.firebirdsql.gds.impl.GDSType.getType("PURE_JAVA"));
        fBBackupManager.setDatabase(fdb.getAbsolutePath());
        System.out.println("restore:"+fBBackupManager.getDatabase());
        fBBackupManager.setUser(DbPath.getDbUser());
        fBBackupManager.setPassword(DbPath.getDbPass());
        fBBackupManager.setHost(DbPath.getDbHost());
        for (int i = 0; i < nbakFiles.length; i++) {
            fBBackupManager.addBackupFile(nbakFiles[i].getAbsolutePath());
        }
        boolean success = false;
        try {
            fBBackupManager.restoreDatabase();
            success = true;
        } catch (SQLException ex1) {
            success = false;
            ex1.printStackTrace();
           
            fBBackupManager.clearBackupFiles();
            fBBackupManager.setDatabase(null);
            ok = fdb_old.renameTo(fdb);//Cannot rename untill jvm restart
            System.out.println("NBAK fail. rename:"+ok);
            deleteFilesInFolder(dirUnzip);//Cannot delete N backup faulty file untill database restart
        }