RMS 1.2 Database Backup

Aug 28, 2005 6 Replies

I am looking for a small batch files that backs up my POS database on a daily basis where the backup file name is the system date and time.



I found a batch file backup with a fixed file name on MS Customer Source but would rather want to keep daily copies.


Thanks Antonio, that's exactly what I was looking for.

Antonio,

I just tried to run the following db_backup.cmd but get an error on the + sign. Here is the exact syntax of the command with the error message:

C:\Program Files\Microsoft Retail Management System>OSQL -U UserName -P password -S TCS50

-Q "BACKUP DATABASE main TO DISK = 'c:\Program Files\Microsoft Retail Management System\Backup\Backup-' + str(year(getdate())) + str(month(getdate())) + str(day(getdate())) '.bck' WITH FORMAT, STATS" Msg 170, Level 15, State 1, Server TCS50, Line 1 Line 1: Incorrect syntax near '+'.

"Gerd" ha scritto nel messaggio news:% snipped-for-privacy@TK2MSFTNGP10.phx.gbl...

BACKUP DTABASE yourdbname TO DISK = 'yourpath\backupdb_' + str(year(getdate())) + str(month(getdate())) + str(day(getdate())) + str(datepart(hh,getdate()))+str(mi(getdate()))+str(datepart(ss,getdate())) '.bck'

"Gerd" ha scritto nel messaggio news: snipped-for-privacy@tk2msftngp13.phx.gbl...

DECLARE @fullpath nvarchar(255)

set @fullpath = 'c:\Program Files\Microsoft Retail Management System\Backup\Backup-' + str(year(getdate())) + str(month(getdate())) + str(day(getdate())) + '.bck'

BACKUP DATABASE main TO DISK = @fullpath WITH FORMAT, STATS

sorry for my error antonio

Hi Antonio,

could I bother you again. I made the changes you specified but now I get the following error message:

C:\Program Files\Microsoft Retail Management System>OSQL -U sa -P password -S TCS50 -Q "BACKUP DATABASE main TO DISK = @fullpath WITH FORMAT, STATS" Msg 137, Level 15, State 2, Server TCS50, Line 1

Here is the complete .cmd file I use:

declare @fullpath nvarchar(255)

set @fullpath = 'c:\Program Files\Microsoft Retail Management System\Backup\Backup-' + str(year(getdate())) + str(month(getdate())) + str(day(getdate())) + '.bck'

OSQL -U sa -P hina -S TCS50 -Q "BACKUP DATABASE main TO DISK = @fullpath WITH FORMAT, STATS"

Please write "DECLARE @FULLPATH NVARCHAR; SET @FULLPATH 'blablablablablablbalba'; BACKUP DATABASE main TO DISK = @FULLPATH WITH FORMAT,STATS"

SQL Server raise an error because the @FULLPATH variable isn't declared.

bye antonio

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required