SqlBackup from my client app
- by Robbert Dam
I have an client app that runs on several machines, and connects to a single SQL database. On the client app, the user has the possiblity to use a local SQL (CE) database or connect to a remote SQL database. There is also a box where a backup location can be set.
For the backup of the remote SQL database I use the following code:
var bdi = new BackupDeviceItem(backupFile, DeviceType.File);
var backup = new Backup
{
Database = "AppDb",
Initialize = true
};
backup.Devices.Add(bdi);
var server = new Server(connection);
backup.SqlBackup(server);
When developing my application, I wasn't aware that the given backupFile is written on the machine where the SQL server runs! And not on the client machine.
What I want is "dump" all the data from my database to a local file.
(Why? Because users may enter a network location in the "backup location" box, and backing up SQL immediately to a network location fails. So need to write local first and then copy to the network in that case.)
I there an alternative to the method above?