Subject Why createBackup and restoreDatabase take different format for Filenames ?
Author Ashok122
I wish restoreDatabase work same way as createBackup.
Can this be fixed ?
I am using Firebird 2.0 and Jaybird 2.1 versions.
Please test this scenario.

Thanks,
Ashok

import java.io.*;
import java.sql.SQLException;
import org.firebirdsql.gds.impl.GDSType;
import org.firebirdsql.management.FBBackupManager; // Needed to create
new BACKUP.

public class TestCase1 {

public static void main(String args[]) {
CreateBackup("c:/backups/big.FDB",
"c:/backups/testNew16.fbk", "STARGAZER"); // Tested OK
/*
Why above createBackup works, but restoreDatabase does not?
RestoreBackup("c:\backups\new2.fdb",
"c:\backups\testNew16.fbk",
"STARGAZER");
*/

// Following works, but I get GDS Exception. 406. No message for
code 406 found.
// How do I get rid of this error?
RestoreBackup("STARGAZER:c:/backups/testNew21.fdb",
"\\\\STARGAZER\\backups\\testNew16.fbk", "STARGAZER");
}

public static void CreateBackup(String sFDBName,
String sFBKName, String sSrvrName) {
String sSrcDBPath_and_fileName = sFDBName;
String sTgtDBPath_and_fileName = sFBKName;
FBBackupManager fb = new FBBackupManager(GDSType.getType("PURE_JAVA"));
fb.setPort(3050);
fb.setHost(sSrvrName);
fb.setLogger(System.out);
fb.setVerbose(true);
fb.setUser("sysdba");
fb.setPassword("masterkey");
fb.setDatabase(sSrcDBPath_and_fileName);
fb.setBackupPath(sTgtDBPath_and_fileName);
try {
fb.backupDatabase();
} catch (SQLException ex) {
ex.printStackTrace();
}
}

public static void RestoreBackup(String sFDBName,
String sFBKName, String sSrvrName) {
String sSrcDBPath_and_fileName = sFDBName;
String sTgtDBPath_and_fileName = sFBKName;
FBBackupManager fb = new FBBackupManager(GDSType.getType("PURE_JAVA"));
fb.setUser("sysdba");
fb.setPort(3050);
fb.setHost(sSrvrName);
fb.setPassword("masterkey");
fb.setLogger(System.out);
fb.setVerbose(true);
fb.setDatabase(sSrcDBPath_and_fileName);
fb.setBackupPath(sTgtDBPath_and_fileName);
fb.setRestoreReplace(false);
try {
fb.restoreDatabase();
} catch (SQLException ex) {
ex.printStackTrace();
}
}

}