使用FirebirdSql.Data.Services.FbBackup将服务器备份到本地文件 [英] Backup server to local file with FirebirdSql.Data.Services.FbBackup

查看:83
本文介绍了使用FirebirdSql.Data.Services.FbBackup将服务器备份到本地文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下代码备份位于我没有写许可权的远程服务器上的数据库:

I'm trying to use following code to backup a database located on a remote server on which I do NOT have write permission :

FbBackup backupSvc = new FbBackup();
backupSvc.ConnectionString = ConnectionStr; // on remote server
backupSvc.BackupFiles.Add(new FbBackupFile(destFile)); // local file
backupSvc.Verbose = true;
backupSvc.Options = FbBackupFlags.IgnoreLimbo;        
backupSvc.ServiceOutput += ServiceOutput;
backupSvc.Execute();

如果数据库位于 localhost 上,或者我可以写入服务器文件夹,则此方法非常好.问题是当我需要将文件保存到本地计算机时(因为我没有服务器权限).奇怪的是,服务输出显示了通常的输出-只是最后没有创建本地文件...!

This works just perfectly fine if the DB is on localhost or if I can write to the server folder. The problem is when I need to save the file to the local machine (since I do NOT have permissions on the server). Weirdly enough, the service output shows the usual output - just that at the end, the local file is NOT created...!

我在此处阅读了有关使用 gbak 的信息,但是在使用该信息时,我遇到了许多其他问题.我很确定有一个缺失的参数或我所缺少的其他任何怪异窍门...

I read here about using gbak, but I ran into many other problems using that. I am pretty sure there is a missing parameter or any other weird trick I'm missing...

推荐答案

FbBackup 类仅实现常规gbak操作,在该操作中,客户端可以触发备份,但是备份是写在服务器上的(使用Firebird服务器进程的访问权限).

The FbBackup class only implements the normal gbak operation where a client can trigger a backup, but the backup is written on the server (using the access rights of the Firebird server process).

如果要在客户端上创建备份,则需要使用 FirebirdSql.Data.Services.FbStreamingBackup .

If you want the backup to be created on the client, you need to use FirebirdSql.Data.Services.FbStreamingBackup instead.

另请参见 https://www.tabsoverspaces.com/233462-ado-net-provider-4-2-0-0-for-firebird-is-ready

一个最小的例子:

static void Main(string[] args)
{
    var connectionString = new FbConnectionStringBuilder
    {
        Database = "employee",
        DataSource = "sagittarius",
        ServerType = FbServerType.Default,
        UserID = "sysdba",
        Password = "masterkey",
    }.ToString();

    using (var output = File.Create(@"D:\Temp\remotebackup.fbk"))
    {
        var backup = new FbStreamingBackup();
        backup.ConnectionString = connectionString;
        backup.OutputStream = output;
        backup.Execute();
    }
    Console.ReadLine();
}

这篇关于使用FirebirdSql.Data.Services.FbBackup将服务器备份到本地文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆