Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Why not make a ordinary backup (easy to do with sqlcommand) and add a feature for the users to easy restore that backupfile with a click on a button?</p> <ul> <li>You can backup the database with sql-commands</li> <li>You can shell out and zip the backupfile with sql-commands</li> <li>You can also shell out and ftp the backupfile automagically to an webserver if you want.</li> </ul> <p>What are the end users using to consume your db? A winform-program? Then it easy done to do everything with a button click for the user.</p> <p>Here are some example code for that:</p> <pre><code>Declare @CustomerID int declare @FileName nvarchar(40) declare @ZipFileName nvarchar(40) declare @ZipComand nvarchar(255) set @CustomerID=20 --Get from database instead in real life application SET @FileName='c:\backups\myback'+ cast(@customerID as nvarchar(10))+'.bak' SET @ZipFileName='c:\backups\myback'+ cast(@customerID as nvarchar(10))+'.zip' --Backup database northwind backup database northwind to DISK=@FileName --Zip the file, I got a commanddriven zip.exe from the net somewhere. set @ZipComand= 'zip.exe -r '+@ZipFileName+' '+@FileName EXEC xp_cmdshell @zipcomand,NO_output --Execute the batfile that ftp:s the file to the server exec xp_cmdshell 'c:\movetoftp.bat',no_output --Done! </code></pre> <p>You have to have a movetoftp.bat that contains this (change ftp-server to your):<br> ftp -s:ftpcommands.txt ftp.myftp.net</p> <p>And you have to have a ftpcommands.txt that contains this (You can have this file created dnamically with just the right zip-file by sqlcommands too, but I let you do that yourself):</p> <p>ftpusername<br> ftppassword<br> binary<br> prompt n<br> mput c:\backups\*.zip<br> quit </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload