如何使用 isql.exe(命令行)将 Sybase 15 数据库备份到文件或从文件恢复?
我正在编写一个 C# 应用程序,它将使用适当的参数调用 isql.exe。
我需要遵守的接口:
public void Backup(string serverName, string databaseName, string userName, string password, string backupDestinationPath);
public void Restore(string serverName, string databaseName, string userName, string password, string restoreSourcePath);
我已经为 MSFT SQL Server 2008 实现了这个。他们有很棒的文档,例如: http://technet.microsoft.com/en-us/library/ms186865.aspx
我想出了一些方法来做到这一点(对于 SQL Server):
BACKUP DATABASE MY_DB
TO DISK = 'C:\Temp\MY_DB.bak'
WITH INIT, SKIP, NOFORMAT, NOUNLOAD,
CHECKSUM, STOP_ON_ERROR,
NAME = 'MY_DB.bak',
DESCRIPTION = 'Backup of MY_DB.';
RESTORE DATABASE MY_DB
FROM DISK = 'C:\Temp\MY_DB.bak'
WITH REPLACE, RECOVERY;
并像这样调用它so(Windows 批处理文件语法):
sqlcmd -E -S %SERVERNAME% -U %USER% -P %PASSWORD% -d master -Q "%SQL_BACKUP_CMD%"
我在网上找不到太多关于如何为 SyBase 执行此操作的信息。
编辑:
我现在可以从命令行执行此操作。首先,我创建一个名为 syb_bak.sql 的文件,其中包含:
dump database mydb to "D:\Temp\mydb.bak"
go
exit
然后,我通过以下两种方式之一在命令行上调用它:
isql.exe -S {serverAlias} -U {user} -P {password} -i syb_bak.sql
isql.exe -S {serverAlias} -U {user} -P {password} < syb_bak.sql
(可选)我可以使用 -o
标志或输出重定向 >< /code> 来获取输出。
一切都很好,除了令我惊讶的是,备份文件被转储到服务器端而不是客户端。
I am writing a C# app that would call the isql.exe
with appropriate arguments.
The interface that I need to conform to:
public void Backup(string serverName, string databaseName, string userName, string password, string backupDestinationPath);
public void Restore(string serverName, string databaseName, string userName, string password, string restoreSourcePath);
I have already implemented this for MSFT SQL Server 2008. They have great documentation, such as: http://technet.microsoft.com/en-us/library/ms186865.aspx
I came up with ways to do it (for SQL Server):
BACKUP DATABASE MY_DB
TO DISK = 'C:\Temp\MY_DB.bak'
WITH INIT, SKIP, NOFORMAT, NOUNLOAD,
CHECKSUM, STOP_ON_ERROR,
NAME = 'MY_DB.bak',
DESCRIPTION = 'Backup of MY_DB.';
RESTORE DATABASE MY_DB
FROM DISK = 'C:\Temp\MY_DB.bak'
WITH REPLACE, RECOVERY;
And call it like so (Windows batch file syntax):
sqlcmd -E -S %SERVERNAME% -U %USER% -P %PASSWORD% -d master -Q "%SQL_BACKUP_CMD%"
I have not been able to find much online about how to do this for SyBase.
EDIT:
I can now do this from the command line. First I create a file named syb_bak.sql containing:
dump database mydb to "D:\Temp\mydb.bak"
go
exit
Then I call it on the command line in one of two ways:
isql.exe -S {serverAlias} -U {user} -P {password} -i syb_bak.sql
isql.exe -S {serverAlias} -U {user} -P {password} < syb_bak.sql
Optionally I can use the -o
flag or an output redirect >
to grab the output.
Everything works great, except that, to my surprise, the backup file is being dumped on the server side and not client.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
转储数据库命令
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.ase_15.0.commands/html/commands/commands54.htm
fe
转储使用 init 将数据库 DB 复制到“/dev/nrmt0”
恢复数据库
加载
rel="nofollow" > 来自“/dev/nrmt0”的数据库
Dump database command
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.ase_15.0.commands/html/commands/commands54.htm
f.e.
dump database DB to "/dev/nrmt0" with init
Restore database
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.ase_15.0.commands/html/commands/commands64.htm
f.e.
load database DB from "/dev/nrmt0"