We're making changes to the Community, so you may have received some notifications - thanks for your patience and welcome back. Learn more here.

Forum Discussion

Michel1955's avatar
Michel1955
Explorer | Level 3
2 months ago

Backup a SQL Server database and transfer it to Dropbox.

Hi,

I want to backup a SQL Server database using a bat file.

This is the contents of the bat file when I backup it on my laptop :

cls
set SERVERNAME=DESKTOP-6PULTF9\SQLEXPRESS05
set DATABASENAME=AssetManagement
set DATABASESHOP=HuntsmanShop
set datestr=%date:~6,4%%date:~3,2%%date:~0,2%
set timestr=%Time:~0,2%%Time:~3,2%%Time:~6,2%
set FileName=%DATABASESHOP%_%DATABASENAME%_%datestr%%timestr%.bak
set BAK_PATH=C:\Data\Test\
set DEST_FILE=%BAK_PATH%%FileName%
:: --------------------------------------------------
:: BACKUP Database
:: NOTE: If error "access is denied" appear - go to service properties - log on.
sqlcmd -E -S %SERVERNAME% -d master -Q "BACKUP DATABASE [%DATABASENAME%] TO DISK = N'%DEST_FILE%' WITH INIT , NOUNLOAD , NAME = N'%DATABASENAME% backup', NOSKIP , STATS = 10, NOFORMAT"

and this works perfectly.

Now when I want to make a backup to a Dropbox folder it doesn't work :

cls
set SERVERNAME=DESKTOP-6PULTF9\SQLEXPRESS05
set DATABASENAME=AssetManagement
set DATABASESHOP=HuntsmanShop
set datestr=%date:~6,4%%date:~3,2%%date:~0,2%
set timestr=%Time:~0,2%%Time:~3,2%%Time:~6,2%
set FileName=%DATABASESHOP%_%DATABASENAME%_%datestr%%timestr%.bak
set BAK_PATH=C:\Users\miche\Dropbox\Huntsman Shop\Backup\
set DEST_FILE=%BAK_PATH%%FileName%
:: --------------------------------------------------
:: BACKUP Database
:: NOTE: If error "access is denied" appear - go to service properties - log on.
sqlcmd -E -S %SERVERNAME% -d master -Q "BACKUP DATABASE [%DATABASENAME%] TO DISK = N'%DEST_FILE%' WITH INIT , NOUNLOAD , NAME = N'%DATABASENAME% backup', NOSKIP , STATS = 10, NOFORMAT"

I have been looking for a solution for a long time but I can't find it.
What am I doing wrong?
Thanks in advance.
Regards
Michel

  • Hey Michel1955 - thanks for using Dropbox and welcome to the Community!

     

    I'm afraid I can't really suggest anything on this, since we usually recommend that people do not sync live databases with Dropbox. 

     

    Most databases have remote access methods anyway, so you don't need to sync the live database. You can sync saved snapshots, however, with no issues.

     

    That said, note that I'll leave this thread open in case other users have something additional to offer and you can let us know if you have anything else to ask. 

  • Walter's avatar
    Walter
    Icon for Dropbox Staff rankDropbox Staff

    Hey Michel1955 - thanks for using Dropbox and welcome to the Community!

     

    I'm afraid I can't really suggest anything on this, since we usually recommend that people do not sync live databases with Dropbox. 

     

    Most databases have remote access methods anyway, so you don't need to sync the live database. You can sync saved snapshots, however, with no issues.

     

    That said, note that I'll leave this thread open in case other users have something additional to offer and you can let us know if you have anything else to ask. 

About View, download, and export

Need support with viewing, downloading, and exporting files and folders from your Dropbox account? Find help from the Dropbox Community.

Need more support

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!