LINUX下备份数据

LINUX下备份数据

Linux上备份Oracle数据库脚本
# exp-backup.sh# initialize oracle database env variable /home/oracle/oraenv# assign current date to variable rq# 注意:定义rq变量用的单引号是tab键上面的~键。 rq=`date +"%y%m%d"`# export whole database exp expuser/web2dump5@ctgpcweb parfile=./export.par file=/backup/db_1634_$rq.dmp log=./db_1634_$rq.log

会发送和抄送邮件的MySQL数据库备份脚本
backupDB_then_mail_it.sh


#!/bin/bash

echo Delete last arthive file\(s\) ...
rm DB_BACKUP.sql.gz

echo Backup MySQL DB\(c156948_wbj123Drupal\) ...
mysqldump --user=c156948admin --password=xxxxxxx --host=mysql4-c c156948_wbj123Drupal | gzip > DB_BACKUP.sql.gz

echo Mail it to [email protected] ...
uuencode DB_BACKUP.sql.gz DB_BACKUP.sql.gz | mail -s "Drupal DB BACKUP of wbj123.com" -c [email protected] [email protected]

解释如下:
先删掉上次备份的旧的备份文件
再备份MySQL数据库
再把数据库的备份文件Email到两个邮箱中

若不要抄送邮件,就改用下面这段

echo Mail it to [email protected] with short title ...
uuencode DB_BACKUP.sql.gz DB.gz | mail -s "DB" [email protected]

你可能感兴趣的:(LINUX下备份数据)