存档
以下操作均由sybase用户来做:
新建一个脚本文件,譬如/sybase/script/dump.sh
类容如下
$ cat dump.sh
/sybase/OCS-12_5/bin/isql -Usa -P******* -S******* -i /sybase/script/dump.sql -o /sybse/script/dump.log
mv /caiwubackup/backup/cwbase1.bak /caiwubackup/backup/cwbase1_`date +%Y%m%d`.bak
mv /caiwubackup/backup/cwbase2.bak /caiwubackup/backup/cwbase2_`date +%Y%m%d`.bak
mv /caiwubackup/backup/cwbase3.bak /caiwubackup/backup/cwbase3_`date +%Y%m%d`.bak
mv /caiwubackup/backup/cwmaster.bak /caiwubackup/backup/cwmaster_`date +%Y%m%d`.bak
mv /caiwubackup/backup/master.bak /caiwubackup/backup/master_`date +%Y%m%d`.bak
(注意:`号是在键盘左上角和波浪线在一起的那个键上,不是单引号)
在同一个目录下新建脚本dump.sql
类容如下
$ cat dump.sql
dump database cwbase1 to "/caiwubackup/backup/cwbase1.bak"
go
dump database cwbase2 to "/caiwubackup/backup/cwbase2.bak"
go
dump database cwbase3 to "/caiwubackup/backup/cwbase3.bak"
go
dump database cwmaster to "/caiwubackup/backup/cwmaster.bak"
go
dump database master to "/caiwubackup/backup/master.bak"
go
制定一个定时计划,每天晚上23点30开始备份数据库
$crontab -e
30 23 * * * /sybase/script/dump.sh
根据你本机的实际情况,修改相关数据库名称和路径。