-
Need help with simple backup script.
Hello,
I run a simple backup on my BES Server to do a backup everyday. The commands I run are as follows:
C:\>osql -E
1> backup database besmgmt1 to disk = "c:\besdbapr19.bak"
2>go
Processed 3112 pages for database 'besmgmt1', file 'BESMgmt1_data' on file 1.
Processed 1 pages for database 'besmgmt1', file 'BESMgmt1_log' on file 1.
BACKUP DATABASE successfully processed 3113 pages in 3.222 seconds (7.913
MB/sec).
Is there a way to script this? I am fairly new to this so some handholding would be required Basically, the script should be smart enough to change file names as well.
Any help would be appreciated.
Thanks....
-
You can use db maintenance plan for that, find details in sql books online.
-
Originally Posted by rmiao
You can use db maintenance plan for that, find details in sql books online.
Kind of a dissappointing answer, If I really had to look at books I wouldn't have seeked help on the forum.
-
a. Create C:\backup.bat with the following code
@echo off
set randomnew=%date:~4,2%%date:~7,2%%date:~10,4%
set SERVERNAME=%1
set DATABASENAME=%2
set LOCATION=%3
set QUERY="BAckup database %DATABASENAME% to disk = '%LOCATION%%DATABASENAME%%randomnew%.bak'"
echo "Backup command is"
echo %QUERY%
echo "Result....."
OSQL -S%SERVERNAME% -E -Q%QUERY%
echo "Backup COmpleted..."
b. go to command prompt
c. execute the batch file passing the following parameters from the command prompt
backup NYTINW60 admin d:\sybback\sybdump\
d. The result will be like as shown below.
"Backup command is"
"BAckup database admin to disk = 'd:\sybback\sybdump\admin04202007.bak'"
"Result....."
Processed 232 pages for database 'admin', file 'admin_data' on file 1.
Processed 1 pages for database 'admin', file 'admin_log' on file 1.
BACKUP DATABASE successfully processed 233 pages in 1.567 seconds (1.213 MB/sec).
"Backup COmpleted..."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|