title: Sql Server Backup and move backup file: How to cope with file permissions?
body: <p>With our product we have a simple backup tool for the sql server database. This tool should <em>just</em> make a full backup and restore to and from any folder.</p>
  
  <p>Of course, the user (usually an administrator) needs permission to write to the target folder.</p>
  
  <p>To avoid the problem of not being able to perform a backup to a network drive, <strong>I write the backup to a temp file in the Sql Server backup directory. Then I move it to the target folder.</strong> This requires permission to delete the temporary file from the sql servers backup folder. Restore is the same in the other direction.</p>
  
  <p>This seemed to work fine until someone tested it on vista, where the <strong>user does not have write access to the backup folder</strong> by default.</p>
  
  <p>So there are many solutions to solve this, but none of them seemed to be really nice.</p>
  
  <p>One solution would be to find another folder for the temporary file. Both the sql server user as well as the administrator performing the backup need read and write permissions. Is there such a directory?</p>
  
  <p>Any other ideas? Thanks a lot.</p>
  
  <hr>
  
  <p><strong>Edit:</strong> Solution must work with Sql Server 2005 and 2008, C# 3.0 (Smo), Windows XP and Vista.</p>