Auto Backup

Does anyone have a .bat script for Microsoft RMS 2.0 for auto backup? I've tried the following, but did not have any luck..

osql -U sa -P password -S servername -Q "BACKUP DATABASE databasename TO DISK = 'c:\database.bck'WITH FORMAT, STATS"

Any help will be greatly appreciated.

Reply to
Steve
Loading thread data ...

What errors are you getting?

Add this to the end so it logs the operation to a text file

Your command line should look like this

osql -U sa -P password -S servername -Q "BACKUP DATABASE databasename TO DISK = 'c:\database.bck' WITH FORMAT, STATS" >> "c:\BackUp-Log.txt"

Check what the BackUp-Log.txt file says after trying and it might give a clue as to what the problem is

Reply to
Michael

Sorry the log file should look like this

10 percent processed. 20 percent processed. 30 percent processed. 40 percent processed. 50 percent processed. 60 percent processed. 70 percent processed. 80 percent processed. 90 percent processed. Processed 154608 pages for database 'DatabaseName', file 'QSDB_Data' on file
  1. 0 percent processed. Processed 2 pages for database 'DatabaseName', file 'QSDB_Log' on file 1. BACKUP DATABASE successfully processed 154610 pages in 88.209 seconds (14.358 MB/sec).
Reply to
Michael

Hi Michael,

Thank you for your response. For some very odd reason, it does not create the backup file or the txt file.

I am replacing the 'password' with the actual database password. Also, I am changing the servername with the computer name which is running the database and the database name is 'database'.

When I run the .bat file, it opens up the command prompt (cmd) and quickly closes the window.

"Michael" wrote:

Reply to
Steve

Try running it from a command line so you can see any error message being generated.

Marc

Reply to
Marc

This script works perfectly, I have been using it for years.

@For /F "tokens=2,3,4 delims=/ " %%A in ('Date /t') do @( Set Month=%%A Set Day=%%B Set Year=%%C )

osql -U sa -P SQLPASSWORD -S NETBIOSNAME -Q "BACKUP DATABASE [DBNAME] TO DISK = 'C:\Path\%Day%-%Month%-%Year%.BCK'"

This is backup the DB and also label it with the date it was backed up > Does anyone have a .bat script for Microsoft RMS 2.0 for auto backup? I've

Reply to
Haik

Reply to
Steve

I know it is a details, but like this it could more easy and flexible : @For /F "tokens=2,3,4 delims=/ " %%A in ('Date /t') do @( Set Month=%%A Set Day=%%B Set Year=%%C ) set BaseName=MyBase set BckDestDir=c:\toMyPath

osql -U sa -P SQLPASSWORD -S NETBIOSNAME -Q "BACKUP DATABASE [%BaseName%] TO DISK = '%BckDestDir%%Day%-%M> Thanks Haik! I will give that a try.

Reply to
Surfzoid

BeanSmart website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.