中文字幕日韩精品一区二区免费_精品一区二区三区国产精品无卡在_国精品无码专区一区二区三区_国产αv三级中文在线

windows和linux環(huán)境自動備份腳本

@echo off   
echo ================================================   
echo  Windows環(huán)境下Oracle數(shù)據(jù)庫的自動備份腳本  
echo  1. 使用當前日期命名備份文件。  
echo  2. 自動刪除7天前的備份。  
echo ================================================  
::以“YYYYMMDD”格式取出當前時間。  
set BACKUPDATE=%date:~0,4%%date:~5,2%%date:~8,2%


::修改字符集。
set NLS_LANG=SIMPLIFIED CHINESE_CHINA.AL32UTF8


::設置用戶名、密碼和要備份的數(shù)據(jù)庫。  
set USER=system
set PASSWORD=oracle
set DATABASE=ORCL


::創(chuàng)建備份目錄。  
if not exist "D:\ORA_BAKUP\data"       mkdir D:\ORA_BAKUP\data
if not exist "D:\ORA_BAKUP\log"        mkdir D:\ORA_BAKUP\log
set DATADIR=D:\ORA_BAKUP\data
set LOGDIR=D:\ORA_BAKUP\log


exp %USER%/%PASSWORD%@ORCL  full=y direct=y recordlength=65535 file=%DATADIR%\exp_%DATABASE%_%BACKUPDATE%.dmp log=%LOGDIR%\exp_%DATABASE%_%BACKUPDATE%.log


::恢復語句
::imp username/passwd@TNS FROMUSER=** TOUSER=** FILE=** LOG=** BUFFER=20480000


::刪除7天前的備份。  
forfiles /p "%DATADIR%" /s /m *.* /d -7 /c "cmd /c del @path"  
forfiles /p "%LOGDIR%" /s /m *.* /d -7 /c "cmd /c del @path"  
exit 


——————Windows日期表示方法——————————————————
echo %Date:~0,10%.rar   
2016/08/08.rar   (注:0,10代指10位)
(所以20160808表示為:)
echo %Date:~0,4%%Date:~5,2%%Date:~8,2%.rar  
20160808.rar
————————————————————————————————————————————
#########################
#Linux備份腳本
#########################
———————————腳本1 datapump—————————————————
集團業(yè)務備份腳本
############################################
#  Backup & Restore Script Using DataPump  #
############################################
export ORACLE_SID=xmtkfpr1
export ORACLE_BASE=/oracle/app/oracle
export ORACLE_HOME=/oracle/app/oracle/product/11.2.0.4/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
current_time=`date '+%Y%m%d'`

##############################
# 1.Backup Script
##############################

expdp userid=jt_wsq/wsq_2016!!! directory=dmp_bak_dir filesize=10G dumpfile=expdp_db_jt_wsq_%U.dmp logfile=expdp_db_jt_wsq_$current_time.log cluster=n parallel=2

##############################
# 2.Recover Script
##############################
#cd /expdata/dmp_bak
#tar -xzvf expdp_db_jt_wsq_$current_time.tar.gz 
#impdp userid=jt_wsq/wsq_2016!!! directory=dmp_bak_dir dumpfile=expdp_db_jt_wsq_%U.dmp logfile=impdp_db_jt_wsq.log parallel=2

##############################
# 3.Comress the Backup
##############################

cd /expdata/dmp_bak/
tar -zcvf  expdp_db_jt_wsq_$current_time.tar.gz expdp_db_jt_wsq_*.dmp --remove-files
find ./ -mtime +20 -name "expdp_db_jt_wsq*" -exec rm -rf {} \;
———————————腳本2 exp/imp————————————————————————————————————————
#Backup for oradb(16.7,16.12)  and SOHUDB(208)
#


echo ============================================
echo Begin Backup Time:`date`
echo ============================================
echo


source ~/.bash_profile
export DATE=`date +'%Y%m%d'`
export NLS_LANG=‘SIMPLIFIED CHINESE_CHINA.AL32UTF8'


#____1.Backup for oradb
cd /home/oracle/backup/oradb
exp bj_dx_immcc/bj_dx_immcc_123@ORADB  recordlength=65535 direct=y file=exp_bj_dx_immcc_$DATE.dmp log=exp_bj_dx_immcc_$DATE.log;
exp bj_dx_immcc_report/bj_dx_immcc_report_123@ORADB   recordlength=65535 direct=y file=exp_bj_dx_immcc_report_$DATE.dmp log=exp_bj_dx_immcc_report_$DATE.log;
exp bj_dx_yyjr/bj_dx_yyjr_123@ORADB   recordlength=65535 direct=y file=exp_bj_dx_yyjr_$DATE.dmp log=exp_bj_dx_yyjr_$DATE.log;




#____2.Backup for SOHODB
cd /home/oracle/backup/SOHODB
exp bj_soho_data/bj_soho_data_123@SOHUDB recordlength=65535 direct=y file=exp_bj_soho_data_$DATE.dmp log=exp_bj_soho_data_$DATE.log;




#____3.Remove Backup 3 Days ago
find /home/oracle/backup/oradb/ -mtime +3 -exec rm -rf {} \;
find /home/oracle/backup/SOHODB/ -mtime +3 -exec rm -rf {} \;


#____4.Recover Script
#imp username/passwd@TNS FROMUSER=** TOUSER=** FILE=** LOG=** BUFFER=20480000


echo
echo ============================================
echo End Backup Time:`date`
echo ============================================


=========================================================
rem 主目錄
set backup_home=D:\database\dump
set NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
set current_date0=%date:~0,4%%date:~5,2%%date:~8,2%
mkdir %backup_home%\%current_date0%
rem 清理兩天前的備份和日志
forfiles /p "%backup_home%" /s /m 20* /d -2 /c "cmd /c rd /s /q @path"  
forfiles /p "%backup_home%\log" /s /m *.log /d -7 /c "cmd /c del @path"  
/*
set YE=%date:~0,4%
set MO=%date:~5,2%
set DA=%date:~8,2%
set DG=2
set/a vY1=%YE% %% 400
set/a vY2=%YE% %% 4
set/a vY3=%YE% %% 100
if %vY1%==0 (set var=true) else (if %vY2%==0 (if %vY3%==0 (set var=false) else (set var=true)) else (set var=false))
set LY=%YE%
set LM=%MO%
if %MO:~0,1%==0 (set MO=%MO:~1,1%)
if %DA:~0,1%==0 (set DA=%DA:~1,1%)
if %DA% GTR %DG% (set/a LD=%DA%-%DG%) else (
if %MO%==1 (set/a LY=%YE%-1) & (set/a LM=12) & (set/a LD=31+%DA%-%DG%) else (
set/a LM=%MO%-1
if %MO%==3 (if %var%==false (set/a LD=28+%DA%-%DG%) else (set/a LD=29+%DA%-%DG%))
for %%a in (2 4 6 8 9 11) do (if "%MO%"=="%%a" (set/a LD=31+%DA%-%DG%))
for %%b in (5 7 10 12) do (if "%MO%"=="%%b" (set/a LD=30+%DA%-%DG%))))
if %LM% LSS 10 set LM=0%LM:~-1%
if %LD% LSS 10 set LD=0%LD:~-3%
set current_date1=%LY%%LM%%LD%
 
rd /s /q  %backup_home%\%current_date1%
*/
rem 備份當前數(shù)據(jù)庫
call exp userid='system/Oracle114#@hbbst' log=%backup_home%\log\backup_db_hbbst_%current_date0%.log parfile=%backup_home%\backup_db_hbbst.par
mv /y %backup_home%\*.dmp %backup_home%\%current_date0%\




===========
owner=bdp
recordlength=32768
buffer=20000000
statistics=none
compress=n
filesize=10g
file=(
D:\database\dump\backup_db_hbbst_001.dmp,
D:\database\dump\backup_db_hbbst_002.dmp,
D:\database\dump\backup_db_hbbst_003.dmp,
D:\database\dump\backup_db_hbbst_004.dmp,
D:\database\dump\backup_db_hbbst_005.dmp,
D:\database\dump\backup_db_hbbst_006.dmp,
D:\database\dump\backup_db_hbbst_007.dmp,
D:\database\dump\backup_db_hbbst_008.dmp,
D:\database\dump\backup_db_hbbst_009.dmp,
D:\database\dump\backup_db_hbbst_010.dmp,
D:\database\dump\backup_db_hbbst_011.dmp,
D:\database\dump\backup_db_hbbst_012.dmp,
D:\database\dump\backup_db_hbbst_013.dmp,
D:\database\dump\backup_db_hbbst_014.dmp,
D:\database\dump\backup_db_hbbst_015.dmp,
D:\database\dump\backup_db_hbbst_016.dmp,
D:\database\dump\backup_db_hbbst_017.dmp,
D:\database\dump\backup_db_hbbst_018.dmp,
D:\database\dump\backup_db_hbbst_019.dmp,
D:\database\dump\backup_db_hbbst_020.dmp,
D:\database\dump\backup_db_hbbst_021.dmp,
D:\database\dump\backup_db_hbbst_022.dmp,
D:\database\dump\backup_db_hbbst_023.dmp,
D:\database\dump\backup_db_hbbst_024.dmp,
D:\database\dump\backup_db_hbbst_025.dmp,
D:\database\dump\backup_db_hbbst_026.dmp,
D:\database\dump\backup_db_hbbst_027.dmp,
D:\database\dump\backup_db_hbbst_028.dmp,
D:\database\dump\backup_db_hbbst_029.dmp,
D:\database\dump\backup_db_hbbst_030.dmp,
D:\database\dump\backup_db_hbbst_031.dmp,
D:\database\dump\backup_db_hbbst_032.dmp,
D:\database\dump\backup_db_hbbst_033.dmp,
D:\database\dump\backup_db_hbbst_034.dmp,
D:\database\dump\backup_db_hbbst_035.dmp,
D:\database\dump\backup_db_hbbst_036.dmp,
D:\database\dump\backup_db_hbbst_037.dmp,
D:\database\dump\backup_db_hbbst_038.dmp,
D:\database\dump\backup_db_hbbst_039.dmp,
D:\database\dump\backup_db_hbbst_040.dmp,
D:\database\dump\backup_db_hbbst_041.dmp,
D:\database\dump\backup_db_hbbst_042.dmp,
D:\database\dump\backup_db_hbbst_043.dmp,
D:\database\dump\backup_db_hbbst_044.dmp,
D:\database\dump\backup_db_hbbst_045.dmp,
D:\database\dump\backup_db_hbbst_046.dmp,
D:\database\dump\backup_db_hbbst_047.dmp,
D:\database\dump\backup_db_hbbst_048.dmp,
D:\database\dump\backup_db_hbbst_049.dmp,
D:\database\dump\backup_db_hbbst_050.dmp,
D:\database\dump\backup_db_hbbst_051.dmp,
D:\database\dump\backup_db_hbbst_052.dmp,
D:\database\dump\backup_db_hbbst_053.dmp,
D:\database\dump\backup_db_hbbst_054.dmp,
D:\database\dump\backup_db_hbbst_055.dmp,
D:\database\dump\backup_db_hbbst_056.dmp,
D:\database\dump\backup_db_hbbst_057.dmp,
D:\database\dump\backup_db_hbbst_058.dmp,
D:\database\dump\backup_db_hbbst_059.dmp,
D:\database\dump\backup_db_hbbst_060.dmp,
D:\database\dump\backup_db_hbbst_061.dmp,
D:\database\dump\backup_db_hbbst_062.dmp,
D:\database\dump\backup_db_hbbst_063.dmp,
D:\database\dump\backup_db_hbbst_064.dmp,
D:\database\dump\backup_db_hbbst_065.dmp,
D:\database\dump\backup_db_hbbst_066.dmp,
D:\database\dump\backup_db_hbbst_067.dmp,
D:\database\dump\backup_db_hbbst_068.dmp,
D:\database\dump\backup_db_hbbst_069.dmp,
D:\database\dump\backup_db_hbbst_070.dmp,
D:\database\dump\backup_db_hbbst_071.dmp,
D:\database\dump\backup_db_hbbst_072.dmp,
D:\database\dump\backup_db_hbbst_073.dmp,
D:\database\dump\backup_db_hbbst_074.dmp,
D:\database\dump\backup_db_hbbst_075.dmp,
D:\database\dump\backup_db_hbbst_076.dmp,
D:\database\dump\backup_db_hbbst_077.dmp,
D:\database\dump\backup_db_hbbst_078.dmp,
D:\database\dump\backup_db_hbbst_079.dmp,
D:\database\dump\backup_db_hbbst_080.dmp,
D:\database\dump\backup_db_hbbst_081.dmp,
D:\database\dump\backup_db_hbbst_082.dmp,
D:\database\dump\backup_db_hbbst_083.dmp,
D:\database\dump\backup_db_hbbst_084.dmp,
D:\database\dump\backup_db_hbbst_085.dmp,
D:\database\dump\backup_db_hbbst_086.dmp,
D:\database\dump\backup_db_hbbst_087.dmp,
D:\database\dump\backup_db_hbbst_088.dmp,
D:\database\dump\backup_db_hbbst_089.dmp,
D:\database\dump\backup_db_hbbst_090.dmp,
D:\database\dump\backup_db_hbbst_091.dmp,
D:\database\dump\backup_db_hbbst_092.dmp,
D:\database\dump\backup_db_hbbst_093.dmp,
D:\database\dump\backup_db_hbbst_094.dmp,
D:\database\dump\backup_db_hbbst_095.dmp,
D:\database\dump\backup_db_hbbst_096.dmp,
D:\database\dump\backup_db_hbbst_097.dmp,
D:\database\dump\backup_db_hbbst_098.dmp,
D:\database\dump\backup_db_hbbst_099.dmp,
D:\database\dump\backup_db_hbbst_100.dmp
)
================================
backup_db_zxin.sh


ORACLE_BASE=/oracle/app/oracle;export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db;export ORACLE_HOME
ORACLE_SID=zxin;export ORACLE_SID
export NLS_LANG=American_America.ZHS16GBK
export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
export AIXTHREAD_SCOPE=S
export LANG=C
TEMP=/tmp; export TEMP 
TMPDIR=/tmp; export TMPDIR
umask 022
PATH=$PATH:$ORACLE_HOME/bin:/usr/bin:/etc:/usr/lbin:/usr/bin/X11:/usr/local/bin
export PATH
LIBRARY_PATH=$ORACLE_HOME/lib32:$LD_LIBRARY_PATH ;export LIBRARY_PATH


current_time=`date '+%Y%m%d'`
dumpfile='expdp_db_zxin_'$current_time'_%U.dmp'
logfile='expdp_db_zxin_'$current_time'.log'
find /oradata1/data_backup/zxin -name "expdp_db_zxin*.dmp" -type f -mtime +1 -exec rm -f {} \;
find /oradata1/data_backup/zxin -name "expdp_db_zxin*.log" -type f -mtime +1 -exec rm -f {} \;
expdp userid=system/*** full=y directory=zxin_expdp_dir filesize=10G dumpfile=$dumpfile logfile=$logfile content=all






ftp_to_p550.sh




#!/bin/bash
current_time=`date '+%Y%m%d'`
ftp -ivn<<!--
user oracle oracle
bin
cd /oradata2/data_backup/zxin
lcd /oradata1/data_backup/zxin
mput *$current_time*.dmp
close
bye
!


===============
0 21 * * * /oradata1/data_backup/zxin/backup_db_zxin.sh > /oradata1/data_backup/zxin/backup_db_zxin.log 2>&1


==MySQL自動備份===========
backup_db_full.sh
echo 'backup is starting.....'
current_time=`date '+%Y%m%d'`
dumpfile='backup_db_sasadb_'$current_time'.sql'
find /apps/data_backup/ -name "backup_db_sasadb*.dmp" -type f -mtime +1 -exec rm -f {} \;
mysqldump -uroot -p'**' database > /apps/data_backup/$dumpfile
echo 'backup is done!'




/u01/mysql/mysql-advanced-5.6.20-linux-glibc2.5-x86_64/bin/mysqldump -uroot  -h 127.0.0.1 -p'1qazxsw#@'  shdxghwx > /u01/data_backup/$dumpfile








@echo off 
cd D:backuup_sql 
forfiles /m *.trn /d -3 /c "cmd /c del *.sql /f"
















本文標題:windows和linux環(huán)境自動備份腳本
文章地址:http://www.rwnh.cn/article24/gpopce.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版虛擬主機、云服務器網(wǎng)站收錄、網(wǎng)站排名網(wǎng)站策劃

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都seo排名網(wǎng)站優(yōu)化
文水县| 水富县| 宜宾市| 上饶县| 沾益县| 大冶市| 旌德县| 达孜县| 陵川县| 收藏| 得荣县| 宁武县| 辽阳市| 历史| 额敏县| 策勒县| 齐河县| 新河县| 巴彦县| 田东县| 尼勒克县| 彭泽县| 佛山市| 五大连池市| 丘北县| 陆良县| 丰顺县| 扎赉特旗| 屏边| 天峻县| 三江| 贡觉县| 樟树市| 龙山县| 扎囊县| 潮州市| 开阳县| 康平县| 湘潭市| 江城| 如皋市|