title: How to backup/restore a Sybase 15 database to/from file using isql.exe (command line)?
body: <p>I am writing a C# app that would call the <code>isql.exe</code> with appropriate arguments.</p>
  
  <p>The interface that I need to conform to:</p>
  
  <pre><code>    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);
  </code></pre>
  
  <p>I have already implemented this for MSFT SQL Server 2008. They have great documentation, such as: <a href="http://technet.microsoft.com/en-us/library/ms186865.aspx" rel="nofollow">http://technet.microsoft.com/en-us/library/ms186865.aspx</a></p>
  
  <p>I came up with ways to do it (for SQL Server):</p>
  
  <pre><code>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;
  </code></pre>
  
  <p>And call it like so (Windows batch file syntax):</p>
  
  <pre><code>sqlcmd -E -S %SERVERNAME% -U %USER% -P %PASSWORD% -d master -Q "%SQL_BACKUP_CMD%"
  </code></pre>
  
  <p>I have not been able to find much online about how to do this for SyBase.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I can now do this from the command line. First I create a file named syb_bak.sql containing:</p>
  
  <pre><code>dump database mydb to "D:\Temp\mydb.bak"
  go
  exit
  </code></pre>
  
  <p>Then I call it on the command line in one of two ways:</p>
  
  <pre><code>isql.exe -S {serverAlias} -U {user} -P {password} -i syb_bak.sql
  isql.exe -S {serverAlias} -U {user} -P {password} &lt; syb_bak.sql
  </code></pre>
  
  <p>Optionally I can use the <code>-o</code> flag or an output redirect <code>&gt;</code> to grab the output.</p>
  
  <p>Everything works great, except that, to my surprise, the backup file is being dumped on the server side and not client.</p>