b) Edit firebird.conf line contained Providers settings to be like this:
Providers = Engine13, Engine12
Note about the plugins order, it is important!
Now you have FB5 embedded distro whis works with FB5 databases AND can fallback to the FB2.5.
In your application just create a backup from FB2.5 database and do a restore with the other name - it will be created as FB5 database.
Note about restore - you have to wait while the file is really closed by the service thread BEFORE starting using it.
Here is a C# snippet for this (yes, we are using Allman brace style):
=======================================================
var tempGbak = Path.GetTempFileName();
var connectionStringFB3 = new FbConnectionStringBuilder
{
Database = DataBaseManager.DatabasePath(_oldDataBaseName),
Charset = "UTF8",
ServerType = FbServerType.Embedded,
ClientLibrary = _fb5LibraryName,
UserID = "sysdba",
Password = "masterkey",
}.ToString();
using (var output = File.Create(tempGbak, 1024 * 1024))
{
var backup = new FbStreamingBackup();
backup.ConnectionString = connectionStringFB3;
backup.OutputStream = output;
backup.Execute();
}
MTLogger.Info("Old database backup completed, restoring...");
var connectionStringFB5 = new FbConnectionStringBuilder
{
Database = DataBaseManager.DatabasePath(_restoredTemporaryDbName),
Charset = "UTF8",
ServerType = FbServerType.Embedded,
ClientLibrary = _fb5LibraryName,
UserID = "sysdba",
Password = "masterkey",
}.ToString();
var restore = new FbRestore();
restore.PageSize = 16 * 1024;
restore.BackupFiles.Add(new FbBackupFile(tempGbak));
restore.ConnectionString = connectionStringFB5;
restore.Options = FbRestoreFlags.Create;
restore.Execute();
restore = null;
while (FileIsLocked(DataBaseManager.DatabasePath(_restoredTemporaryDbName)))
{
Thread.Sleep(500); // 500 ms to sleep
if (FileIsLocked(DataBaseManager.DatabasePath(_restoredTemporaryDbName)))
{
MTLogger.Debug($"File [{_restoredTemporaryDbName}] is being locked by another thread/process, waiting it to be released...");
}
else
{
break;
}
}
MTLogger.Info("New database restore completed, dealing with orders db if any...");
=======================================================
--
Best regards,