Listing backups with RMAN
When to use it
When you need to confirm from RMAN itself what backups exist, for example before maintenance or when someone asks "can we restore to yesterday?".
Run this
Script: rman_list_backups.sh. Full version in Administration › Utility scripts › Startup, shutdown and backups.
#!/bin/bash
# RMAN Commands - Listar backups de archive logs
# ================================================
# Configure o ambiente
export ORACLE_HOME=/path/to/oracle
export ORACLE_SID=your_db_name
export PATH=$ORACLE_HOME/bin:$PATH
# 1. Listar últimos backups de archive
rman target / << EOF
LIST BACKUP OF ARCHIVELOG RECENT;
EOF
# 2. Listar backups de archive com detalhes completos
rman target / << EOF
LIST BACKUP OF ARCHIVELOG;
EOF
# 3. Listar backups de arquivo em um período específico
rman target / << EOF
LIST BACKUP OF ARCHIVELOG FROM TIME 'sysdate-7';
EOF
# 4. Listar apenas backups completados
rman target / << EOF
LIST BACKUP OF ARCHIVELOG COMPLETED BETWEEN 'trunc(sysdate)-7' AND 'sysdate';
EOF
# 5. Listar com mais detalhes (backup pieces)
rman target / << EOF
LIST BACKUP OF ARCHIVELOG BY BACKUP;
EOF
# 6. Listar backups disponíveis para restore
rman target / << EOF
LIST BACKUP OF ARCHIVELOG;
RUN {
REPORT ARCHIVELOG ALL;
}
EOF
# 7. Verificar coverage de archive logs por backups
rman target / << EOF
REPORT ARCHIVELOG ALL;
EOF
# 8. Listar com summary
rman target / << EOF
LIST BACKUP OF ARCHIVELOG SUMMARY;
EOF
# 9. Exemplo: Listar últimos 10 backups de archive
rman target / << EOF
SET PAGESIZE 100 LINESIZE 100
LIST BACKUP OF ARCHIVELOG RECENT FETCH FIRST 10 ROWS ONLY;
EOF
# 10. Backup status - Se Backup catalog está disponível
rman target / catalog rman_catalog_user/password@recovery_catalog << EOF
LIST BACKUP OF ARCHIVELOG;
EOF
Each block in this file is a separate example. Set ORACLE_HOME and ORACLE_SID first and run the block you need, not the whole file.
Two more read only commands worth knowing:
rman target / <<EOF
LIST BACKUP SUMMARY;
REPORT NEED BACKUP;
SHOW ALL;
EOF
How to read the output
LIST BACKUP SUMMARYgives one line per backup set: type (Dfull,Iincremental,Larchive log), status and completion time.- Status
Ameans available.Xmeans expired: RMAN looked for the file and did not find it. REPORT NEED BACKUPlists files that do not meet the retention policy. An empty list is the good answer.SHOW ALLshows the RMAN configuration, including the retention policy.
What to do next
- Expired backups or files that need backup must be reported the same day.
- Do not run
DELETE,CROSSCHECKorRESTOREon your own. Those are senior DBA tasks. - Read the cheat sheet in Reference › Cheat sheets › Backup and Recovery for the commands a restore uses.
Risk level
READ ONLY Safe to run at any time. It only queries the data dictionary.