quinta-feira, 20 de junho de 2013

Backup RMAN - Alguns scripts

Boa tarde jovens.

Vou postar aqui um script de backup (e suas variações) que está mais que testado e que me ajuda bastante quando preciso fazer algo rápido e manual.

==================
-- Backup
==================
rman target / << EOF
run {
    allocate channel d1 type disk MAXPIECESIZE 8G;
    SQL 'ALTER SYSTEM ARCHIVE LOG CURRENT';
    SQL 'ALTER SYSTEM CHECKPOINT';
    backup AS COMPRESSED BACKUPSET format '/backups/PROD/%d_%Y%M%D_%I_%s_%U.dat' database;
    sql 'alter system archive log current';
    backup AS COMPRESSED BACKUPSET format '/backups/PROD/%d_%Y%M%D_%I_%s_%U.dat' archivelog all;
    release channel d1;
}
exit;
EOF


==================
-- Backup deletando archives e backupsets
==================
rman target / <

run {
    allocate channel d1 type disk MAXPIECESIZE 8G;
    SQL 'ALTER SYSTEM ARCHIVE LOG CURRENT';
    SQL 'ALTER SYSTEM CHECKPOINT';
    backup AS COMPRESSED BACKUPSET format '/backups/PROD/%d_%Y%M%D_%I_%s_%U.dat' database;
    sql 'alter system archive log current';
    backup AS COMPRESSED BACKUPSET format '/backups/PROD/%d_%Y%M%D_%I_%s_%U.dat' archivelog all;
    DELETE NOPROMPT ARCHIVELOG UNTIL TIME 'SYSDATE-5';
    DELETE NOPROMPT OBSOLETE DEVICE TYPE DISK;
    release channel d1;
}
exit;
EOF

========================
-- Backup somente de archives
========================
rman target / <

run {
    allocate channel d1 type disk MAXPIECESIZE 8G;
    SQL 'ALTER SYSTEM ARCHIVE LOG CURRENT';
    SQL 'ALTER SYSTEM CHECKPOINT';
    backup AS COMPRESSED BACKUPSET format '/backups/PROD/%d_%Y%M%D_%I_%s_%U.dat' archivelog all;
    release channel d1;
}
exit;
EOF

Simples e objetivo caso precise rodar algo manualmente.

Abraço
Mario

Nenhum comentário:

Postar um comentário

Isso te ajudou? Comente...

Postagem em destaque

[ORACLE] Increasing the number of cores in a virtualized Oracle Database Appliance.

Hello everyone. How are you going? Today, I'll show you the process to increase the number of cores in a virtualized ODA HA X7-2. Import...