views:

2468

answers:

3

I need to do some structural changes to a database (alter tables, add new columns, change some rows etc) but I need to make sure that if something goes wrong i can rollback to initial state:

  • All needed changes are inside a SQL script file.
  • I don't have administrative access to database.
  • I really need to ensure the backup is done on server side since the BD has more than 30 GB of data.
  • I need to use sqlplus (under a ssh dedicated session over a vpn)
  • Its not possible to use "flashback database"! It's off and i can't stop the database.

Am i in really deep $#$%?

Any ideas how to backup the database using sqlplus and leaving the backup on db server?

+2  A: 

An alternate approach might be to create a new schema that contains your modified structures and data and actually test with that. That presumes you have enough space on your DB server to hold all the test data. You really should have a pretty good idea your changes are going to work before dumping them on a production environment.

I wouldn't use sqlplus to do this. Take a look at export/import. The export utility will grab the definitions and data for your database (can be done in read consistent mode). The import utility will read this file and create the database structures from it. However, access to these utilities does require permissions to be granted, particularly if you need to backup the whole database, not just a schema.

That said, it's somewhat troubling that you're expected to perform the tasks of a DBA (alter tables, backup database, etc) without administrative rights. I think I would be at least asking for the help of a DBA to oversee your approach before you start, if not insisting that the DBA (or someone with appropriate privileges and knowledge) actually perform the modifications to the database and help recover if necessary.

DCookie
Thks 4 your answer.
sakana
+1  A: 

Trying to back up 30GB of data through sqlplus is insane, It will take several hours to do and require 3x to 5x as much disk space, and may not be possible to restore without more testing.

You need to use exp and imp. These are command line tools designed to backup and restore the database. They are command line tools, which if you have access to sqlplus via your ssh, you have access to imp/exp. You don't need administrator access to use them. They will dump the database (with al tables, triggers, views, procedures) for the user(s) you have access to.

Thomas Jones-Low
Seems to be a good approach near of what i'm looking for. Thks :)
sakana
+3  A: 

better than exp/imp, you should use rman. it's built specifically for this purpose, it can do hot backup/restore and if you completely screw up, you're still OK.

One 'gotcha' is that you have to backup the $ORACLE_HOME directory too (in my experience) because you need that locally stored information to recover the control files.

a search of rman on google gives some VERY good information on the first page.

KevinDTimm
rman requires system or sys login to create the catalog to to backups. But, given DBA access, rman is much better than imp/exp or datapump.
Thomas Jones-Low
I assume that if somebody has to do a backup they have these permissions. Otherwise, they're so hamstrung from the beginning they can't possibly be effective.
KevinDTimm