如何在sybase sql server中自动备份数据库,和实现ms sqlserver的作业功能
急!有没有不用不用前台程序的方法,请各位大虾执教! 问题点数:100、回复次数:2Top
1 楼lesni(乐S你)回复于 2001-11-27 14:06:13 得分 0
写个存储过程,定时调用。Top
2 楼killerdanny(堕落的瓦拉斯塔兹)回复于 2001-11-27 14:20:07 得分 100
你如果有时间看看下面E文的!将会很有帮助的!
你仔细看看例子和带*的部分
///////////////////////////////////////////
Backup your running ASA database
//////////////////////////////////////////
With the introduction of ASA 7 there are enhancements to the DbBackup abd DbValid command line utilities. Both utilities can be used on a running database.
Any database backup necessitates good practices to ensure data recovery if necessary. See the ASA 7 on-line documentation for backup/recovery procedures.
*****************************************************************************
A simple batch or command file can be used to accomplish the backup and run from a scheduler. For Windows NT/2000 you can use the Windows Scheduler (AT) to automatically run the backup on a daily basis.
*****************************************************************************
Prior to running a backup – you should perform a full data integrity check of the database to ensure that bad data is not backed up. This is accomplished with the use of DbValid in the below example.
A sample bat file for the validation and backup of a database is below. If an error occurs during the validation or backup, the process stops and the command window remains open with an error message.
= = = = = SAMPLE = = =
@echo off
cls
rem if %1. == . goto usage
echo Performing DB Validation
dbvalid -f -q -c "eng=mydb;dbn=mydb_db;uid=dba;pwd=sql"
if errorlevel 0 goto backupdb
echo ===============================
echo Error Code - %errorlevel%
echo Error in DB Validation - no backup completed
echo ===============================
goto stayopen
:backupdb
echo Performing DB Backup
dbbackup -x -y -q -c "eng=mydb;dbn=mydb_db;uid=dba;pwd=sql"
"d:\backupfiles\mydb”
if errorlevel 0 goto done
echo ===============================
echo Error Code - %errorlevel%
echo Error in DB backup - no backup completed
echo ===============================
goto stayopen
:done
exit
:usage
echo -
echo usage:
echo backit {backup directory}
echo -
:stayopen
= = = = = END SAMPLE = = = =
DbValid
With the command line Validation utility, you can validate the indexes and keys on some or all of the tables in the database. This utility scans the entire table, and confirms that each row in the table exists in the appropriate indexes. It is equivalent to running the VALIDATE TABLE statement on each table.
Syntax : dbvalid [ switches ] [ object-name,... ]
object-name : The name of a table or (if -i is used) an index to validate
-c "keyword=value; ..." : Supply database connection parameters
-o filename : Log output messages to a file
-f : Validate tables with full check
-fd : Validate tables with data check
-fi : Validate tables with index check
-I : Each object-name is an index
-q : Quiet mode—do not print messages
-t : Each object-name is a table
DbValid Options
Connection parameters (-c) For a description of the connection parameters, see Connection parameters. The user ID must have DBA authority or REMOTE DBA authority.
For example, the following validates the sample database, connecting as user DBA with password SQL:
dbvalid -c "uid=DBA;pwd=SQL;dbf=c:\asa6\asademo.db"
Data check for each table (-fd) In addition to the default validation checks, check that all of each LONG BINARY, LONG VARCHAR, TEXT, or IMAGE data type can be read. This corresponds to the WITH DATA CHECK option on the VALIDATE TABLE statement. Depending on the contents of your database, this option may significantly extend the time required to validate.
Full check for each table (-f) In addition to the default validation checks, carry out both data checks (-fd) and index checks (-fi). This corresponds to the WITH FULL CHECK option on the VALIDATE TABLE statement. Depending on the contents of your database, this option may significantly extend the time required to validate.
Index check for each table (-fi) In addition to the default validation checks, validate each index on the table. This corresponds to the WITH INDEX CHECK option on the VALIDATE TABLE statement. Depending on the contents of your database, this option may significantly extend the time required to validate.
Validate specified indexes (-i) Instead of validating tables, validate indexes. In this case, for dbvalid, each of the object-name values supplied represents an index rather than a table, and has a name of the following form:
[ [ owner.]table-name.]index-name
Log output messages to file (-o) Write output messages to the named file.
Operate quietly (-q) Do not display output messages. This option is available only from the command-line utility.
Validate tables (-t) The list of object-name values represents a list of tables. This is also the default behavior.
DbBackup
If none of the switches -d, -t, or -w are used, all database files are backed up.
dbbackup [ switches ] directory
-c "keyword=value; ..." : Supply database connection parameters
-d : Only back up the main database file
-l file : Live backup of the transaction log to a file
-n : Change the naming convention for the backup transaction log
-o filename : Log output messages to a file
-q : Quiet mode—do not print messages
-r : Rename and start a new transaction log
-t : Only back up the transaction log
-w : Only back up the write file
-x : Delete and restart the transaction log
-xo : Delete and restart the transaction log without making a backup
-y : Replace files without confirmation
DbBackup Options:
the directory does not exist, it is created. However, the parent directory must exist.
Connection parameters (-c) For a description of the connection parameters, see Connection parameters. If the connection parameters are not specified, connection parameters from the SQLCONNECT environment variable are used, if set. The user ID must have DBA authority or REMOTE DBA authority.
For example, the following command backs up the asademo database running on the server sample_server, connecting as user ID DBA with password SQL, into the asabackup directory:
dbbackup -c "eng=sample_server;dbn=asademo;uid=DBA;pwd=SQL" asabackup
Backup main database only (-d) Back up the main database files only, without backing up the transaction log file or a write file, if one exists.
Live backup (-l lower-case L) This option is provided to enable a secondary system to be brought up rapidly in the event of a server crash. A live backup does not terminate, but continues running while the server runs. It runs until the primary server crashes. At that point, it is shut down, but the backed up log file is intact and can be used to bring a secondary system up quickly.
Change backup transaction log naming convention (-n) This option is used in conjunction with -r. It changes the naming convention of the backup transaction log file to yymmddnn.log, where nn is a number from 00 to 99 and yymmdd represents the current year, month and day.
The backup copy of the transaction log file is stored in the directory specified on the command line, and with the yymmddnn.log naming convention. This allows backups of multiple versions of the transaction log file to be kept in the same backup directory.
The two-digit year notation does not cause any year 2000 problems. The names are used solely for identification, not for ordering.
Log output messages to file (-o) Write output messages to the named file.
Operate quietly (-q) Do not display output messages. This option is available only from the command-line utility.
Rename and start new transaction log (-r) This option forces a checkpoint and the following three steps to occur:
Step 1 The current working transaction log file is copied and saved to the directory specified in the command line.
Step 2 The current transaction log remains in its current directory, but is renamed using the format yymmddxx.log, where xx is a number from 00 to 99 and yymmdd represents the current year, month and day. This file is then no longer the current transaction log.
Step 3 A new transaction log file is generated that contains no transactions. It is given the name of the file that was previously considered the current transaction log, and is used by the database server as the current transaction log.
Back up the transaction log file only (-t) This can be used as an incremental backup since the transaction log can be applied to the most recently backed up copy of the database file(s).
Back up the database write file only (-w) For a description of database write files, see The Write File utility.
Delete and restart the transaction log (-x) Back up the existing transaction log, then delete the original log and start a new transaction log. This option causes the backup to wait for a point when all transactions from all connections are committed.
Delete and restart the transaction log without a backup (-xo) Delete the current transaction log and start a new one. This operation does not carry out a backup; its purpose is to free up disk space in non-replication environments.
Operate without confirming actions (-y) Choosing this option creates the backup directory or the replacement of a previous backup file in the directory without confirmation.
Top




