How would one migrate from Firebird 2.5.9 to 5.0 when embedded version is in the field?

30 views
Skip to first unread message

Steve Naidamast

unread,
Jan 15, 2024, 1:06:03 PMJan 15
to firebird-general
Hello...

I know that many of us who are still using Firebird 2.5.9 need to consider upgrading to the latest version, 5.0.

However, my application, which is still being developed and uses Firebird 2.5.9 Embedded Edition, is for distribution over the Internet as Open Source.

As a result, what would be a suggestion for making the user experience as easy as possible when changing databases within the application where the application can take care of the field upgrade seamlessly?

I have already developed a script system that upgrades the current database with all the new database objects that have been added with each new release of my software.  As a result, there should be some way to refine my script system to do the same when upgrading the database and uploading the user data to it.

Thank you...

Steve Naidamast
Sr. Software Engineer

Stefan Heymann

unread,
Jan 15, 2024, 4:29:20 PMJan 15
to firebird...@googlegroups.com
Steve,

in order to migrate the databases from 2.5 to 5.0, you will need to run a GBAK backup (using the 2.5 GBAK) and then a restore using the 5.0 GBAK. When you put the gbak.exe in the same folder as the fbclient.dll, you can call GBAK without any problems, it will also run against the embedded database.

So you will need some code in your application (or in the update installer of your application) that performs the backup, then exchanges the files needed for embedded Firebird and then runs the restore. It would e.g. be possible to create a batch file on the fly, that does the backup, the file exchange and the restore and then run this batch script and wait until it is done.

If your application is a Win32 application, make sure to use the 32-bit gbak.exe from the Win32 Zip Firebird distribution.


HTH

Best Regards

Stefan


----- Ursprüngliche Nachricht / Original Message -----
Von/From: Steve Naidamast <blackfalc...@gmail.com>
Gesendet/Date: 15.01.2024 19:06
An/To: firebird-general <firebird...@googlegroups.com>
Betreff/Subject: [firebird-general] How would one migrate from Firebird 2.5.9 to 5.0 when embedded version is in the field?
--
You received this message because you are subscribed to the Google Groups "firebird-general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebird-gener...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/firebird-general/f29fddde-3251-4583-8616-a0ff8912814cn%40googlegroups.com.

Sergey Mereutsa

unread,
Jan 15, 2024, 5:43:24 PMJan 15
to firebird...@googlegroups.com
Hello Steve,

it is really easy - you just have to create a "tricky" embedded version of FB5, which contains Engine12.dll/so/dylib.

I solved nearly the same task recently, so this is my solution.

I`ll show an example using the Windows version, but for Linux/Mac the procedure is similar.

1) Create your own FB5 distribution. You need to add to the standard version 2 things:
a) engine12.dll should be placed in the plugins directory. I also added runtime libraries (msvcp100.dll, msvcr100.dll, msvcr100_clr0400.dll), but I am not sure if they are needed for your case.
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,
 Sergey                            mailto:se...@dqteam.com



--

Mark Rotteveel

unread,
Jan 16, 2024, 4:35:41 AMJan 16
to firebird...@googlegroups.com
On 15/01/2024 23:42, Sergey Mereutsa wrote:
> Hello Steve,
>
> it is really easy - you just have to create a "tricky" embedded version
> of FB5, which contains Engine12.dll/so/dylib.

Engine12 is Firebird 3.0, not Firebird 2.5.

Mark
--
Mark Rotteveel

Sergey Mereutsa

unread,
Jan 16, 2024, 5:00:14 AMJan 16
to firebird...@googlegroups.com
Mark, Steve,

sorry, it is my fault - really, FB2.5 is a bit older.

Plugin's interface is available only from 3.0, IIRC.

--
Best regards,
 Sergey                            mailto:se...@dqteam.com

--
You received this message because you are subscribed to the Google Groups "firebird-general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebird-gener...@googlegroups.com.

Steve Naidamast

unread,
Jan 18, 2024, 11:56:03 AMJan 18
to firebird-general
Thank you all for your very helpful comments...   :-)

Steve Naidamast
Sr. Software Engineer

Reply all
Reply to author
Forward
0 new messages