- For individual users
- Instant access to solutions
- Ask your tech questions
- Start your 30-day Free Trial
Main Topics
Browse All TopicsI have a backup script that I manually run on a windows 2003 server which I will include below.I manually change the backup directory name everyday before I run the script. But this is a hassle when I have a day of and so. I wanted to schedule this job in windows so that this script can run automatically. I tried to schedule it already but somehow it can not do the connection part. so I want to know what needs to be added and how it needs to be added to this script so that it can set the environment, start sqlus and login and run the alter tablespace begin backup lines, create a backup controlfile that is able to recover the db with when needed, include the copy of the spfile to the backup directory and also the last archive log that is create with the alter system switch log statement this last archlog file needs to be copied or go the backup directory also. I want the files to be zipped also and I do have the special winzip module for that but don't know how to use it in a script.
I wanted the script to create a new directory every day so that the backup can go to a different directory every day. But I don't know or I don't have the knowledge to be able to script something like that. I think if this line can go at the first line and then if somehow it is projected in the ocopy command so that it uses that new directory everyday and so I don't need to change the script every day.
What also will work I think is that I create 7 directories and 7 scripts and schedule 7 backups in the schedular which will be easier. Then this directories will be overwritten every week. But I still needs the tips of how to script the start of sqlus, the login and the copy or creation of the backup controlfile, the arch log and the parameter file to the backup directory.
I don't want to use RMAN yet because I don't understand it so good and most of our databases are on unix with perfect scripts that does everything we want but this one is on Windows and that is my weakness here.
this is the script:
spool d:\oracle\backup\cusdb\BU1
alter tablespace system
begin backup;
host ocopy D:\ORACLE\ORADATA\cusdb\SY
alter tablespace system
end backup;
alter tablespace undotbs
begin backup;
host ocopy D:\ORACLE\ORADATA\cusdb\UN
alter tablespace undotbs
end backup;
alter tablespace drsys
begin backup;
host ocopy D:\ORACLE\ORADATA\cusdb\DR
alter tablespace drsys
end backup;
alter tablespace example
begin backup;
host ocopy D:\ORACLE\ORADATA\cusdb\EX
alter tablespace example
end backup;
alter tablespace indx
begin backup;
host ocopy D:\ORACLE\ORADATA\cusdb\IN
alter tablespace indx
end backup;
alter tablespace tools
begin backup;
host ocopy D:\ORACLE\ORADATA\cusdb\TO
alter tablespace tools
end backup;
alter tablespace users
begin backup;
host ocopy D:\ORACLE\ORADATA\cusdb\US
alter tablespace users
end backup;
alter tablespace arch1cts
begin backup;
host ocopy D:\ORACLE\ORADATA\cusdb\AR
alter tablespace arch1cts
end backup;
alter tablespace idx1cts
begin backup;
host ocopy D:\ORACLE\ORADATA\cusdb\ID
alter tablespace idx1cts
end backup;
alter tablespace idxcsa
begin backup;
host ocopy D:\ORACLE\ORADATA\cusdb\ID
alter tablespace idxcsa
end backup;
alter tablespace datcsa
begin backup;
host ocopy D:\ORACLE\ORADATA\cusdb\DA
alter tablespace datcsa
end backup;
alter tablespace dat1cts
begin backup;
host ocopy D:\ORACLE\ORADATA\cusdb\DA
alter tablespace dat1cts
end backup;
alter system switch logfile;
alter database backup controlfile to 'd:\oracle\backup\cusdb\BU
spool off
exit
This question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership