一、單獨備份
1、經典整庫備份:backup as compressed backupset database include current controlfile plus archivelog delete all input;
2、tablespace:backup tablespace 名字;
3、數據文件:backup datafile n; (n:具體的數據文件編號select file_name,file_id,tablespace_name from dba_data_files;)
4、控制文件:backup current controlfile;或者backup database include current controlfile;
5、日志文件:backup archivelog all;或者 database plus archivelog;
6、參數文件:backup spfile;
7、全庫備份腳本:
復制代碼 代碼如下:
run{
allocate channel c1 type disk;
backup full tag ‘dbfull' format ‘/backup/full%u_%s_%p' database
include current controlfile;
sql ‘alter system archive log current'; #在數據庫進行全備份完成之後,需要執行該條命令將當前日志歸檔,備份歸檔日志時應該包括最後生成的歸檔
backup filesperset 3 format ‘/backup/arch%u_%s_%p'#filesperset 3設定每個備份集裡文件不超過3個
archivelog all delete input; #備份歸檔可選,可以單獨定期備份
release channel c1;
}
二、增量備份
1、0級增量備份
復制代碼 代碼如下:
run{
allocate channel c1 type disk;
backup incremental level 0 tag ‘db0' format ‘/backup/db0%u_%s_%p'database
include current controlfile; ;
sql 'alter system archive log current';#在數據庫進行全備份完成之後,需要執行該條命令將當前日志歸檔,備份歸檔日志時應該包括最後生成的歸檔
backup filesperset 3 format ‘/backup/arch%u_%s_%p'#filesperset 3設定每個備份集裡文件不超過3個
archivelog all delete input; #備份歸檔可選,可以單獨定期備份
release channel c1;
}
2、1級備份腳本
復制代碼 代碼如下:
run{
allocate channel c1 type disk;
backup incremental level 1 tag ‘db1' format ‘/backup/db1%u_%s_%p'
database skip readonly include current controlfile;
backup filesperset 3 format ‘/backup/arch%u_%s_%p'#filesperset設定每個備份集裡文件不超過3個
archivelog all delete input; #備份歸檔可選,可以單獨定期備份
release channel c1;
}