col X noprint
col Y format a60 head "Backup DIV2002:UF1"
col Z format a60 head "Restore DIV2002:UF1"
SET VERIFY OFF ECHO OFF FEEDBACK OFF
DEFINE target=c:\oraclass

SELECT sum( megas ) "BackupSize MB"
FROM (
  SELECT sum(bytes)/1048576 megas FROM v$datafile
  union all
  SELECT sum(bytes)/1048576 megas FROM v$tempfile
  union all
  SELECT 410 megas FROM dual
)
/

SELECT 1 "X", 'mkdir &target.\backup\' "Y" FROM dual
union
SELECT 1, 'mkdir &target.\backup' || substr(name,1,7) FROM v$controlfile
union
SELECT 1, 'mkdir &target.\backup' || substr(name,1,7) FROM v$datafile
union
SELECT 1, 'mkdir &target.\backup' || substr(name,1,7) FROM v$tempfile
union
SELECT 1, 'mkdir &target.\backup' || substr(member,1,7) FROM v$logfile
union
SELECT 1, 'mkdir &target.\backup' || substr(name,1,7)||substr(name,8,instr(substr(name,8,10),'\')) FROM v$controlfile
union
SELECT 1, 'mkdir &target.\backup' || substr(name,1,7)||substr(name,8,instr(substr(name,8,10),'\')) FROM v$datafile
union
SELECT 1, 'mkdir &target.\backup' || substr(name,1,7)||substr(name,8,instr(substr(name,8,10),'\')) FROM v$tempfile
union
SELECT 1, 'mkdir &target.\backup' || substr(member,1,7)||substr(member,8,instr(substr(member,8,10),'\')) FROM v$logfile
union
SELECT 2, '' FROM dual
union
SELECT 3, 'copy ' || substr(name,1,7)||substr(name,8,instr(substr(name,8,10),'/')) || 'div2002/* &target.\backup' || substr(name,1,7)||substr(name,8,instr(substr(name,8,10),'/')) FROM v$controlfile
union
SELECT 3, 'copy ' || substr(name,1,7)||substr(name,8,instr(substr(name,8,10),'/')) || 'div2002/* &target.\backup' || substr(name,1,7)||substr(name,8,instr(substr(name,8,10),'/')) FROM v$datafile
union
SELECT 3, 'copy ' || substr(name,1,7)||substr(name,8,instr(substr(name,8,10),'/')) || 'div2002/* &target.\backup' || substr(name,1,7)||substr(name,8,instr(substr(name,8,10),'/')) FROM v$tempfile
union
SELECT 3, 'copy ' || substr(member,1,7)||substr(member,8,instr(substr(member,8,10),'/')) || 'div2002/* &target.\backup' || substr(member,1,7)||substr(member,8,instr(substr(member,8,10),'/')) FROM v$logfile
union
SELECT 4, '' FROM dual
/

SELECT 0 "X", 'touch \&target.\backup\restore.sh' "Z" FROM dual
union
SELECT 1, 'chmod g+x,u+x \&target.\backup\restore.sh' FROM dual
union
SELECT 2, 'vi \&target.\backup\restore.sh' FROM dual
union
SELECT 3, 'i### Restauracao do banco DIV2002 ###' FROM dual
union
SELECT 4, 'cp &target.\backup' || substr(name,1,7)||substr(name,8,instr(substr(name,8,10),'/')) || '* ' || substr(name,1,7)||substr(name,8,instr(substr(name,8,10),'/')) || 'div2002/'  FROM v$controlfile
union
SELECT 4, 'cp &target.\backup' || substr(name,1,7)||substr(name,8,instr(substr(name,8,10),'/')) || '* ' || substr(name,1,7)||substr(name,8,instr(substr(name,8,10),'/')) || 'div2002/'  FROM v$datafile
union
SELECT 4, 'cp &target.\backup' || substr(name,1,7)||substr(name,8,instr(substr(name,8,10),'/')) || '* ' || substr(name,1,7)||substr(name,8,instr(substr(name,8,10),'/')) || 'div2002/'  FROM v$tempfile
union
SELECT 4, 'cp &target.\backup' || substr(member,1,7)||substr(member,8,instr(substr(member,8,10),'/')) || '* ' || substr(member,1,7)||substr(member,8,instr(substr(member,8,10),'/')) || 'div2002/' FROM v$logfile
union
SELECT 5, '' FROM dual
/

col X clear
col Y clear
col Z clear
SET VERIFY ON ECHO OFF FEEDBACK ON
UNDEFINE target

hostgator