You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

Michel1955's avatar
Michel1955
Explorer | Level 3
3 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.