Iam having a weekly full backup in my database what i need is a script that first verify the new backup if it is valid then delete the old one
iam doing this for saving space on my filesystem
the Oracle database version = 12c
Append this checking at initial RMAN script
rman> crosscheck backup;
rman> crosscheck copy;
rman> delete noprompt expired backupset;
# Compress backup to reduce space (lab/test is ok, prod have to pay for license)
CONFIGURE COMPRESSION ALGORITHM 'HIGH' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD FALSE;
...
# database backup takes place here!
...
Append this deletion at the end of current RMAN Script
rman> configure retention policy to redundancy 1;
rman> crosscheck backup;
rman> crosscheck copy;
rman> delete noprompt obsolete;
Related
I am trying to backup an Oracle 19c Database using RMAN but I seem to be running into a few hiccups. What I did first was create test tables and users in the database before backup. Within RMAN I then ran
RMAN> BACKUP DATABASE PLUS ARCHIVELOG;
With the database backed up I then dropped the test tables and users I created and starting restoring the database
RMAN> restore controlfile from 'LOCATIN OF CONTROLFILE';
RMAN> ALTER DATABASE MOUNT;
RMAN> RESTORE DATABASE;
RMAN> RECOVER DATABASE;
RMAN> ALTER DATABASE OPEN RESETLOGS;
When I then connected to the database, it is missing all the tables and users I deleted. I'm not sure whether if I needed to update my datafiles or there is a step that I am overlooking. Thank you
You have to use
Set until SCn
and provide a SCn before you are dropping the tables and and tablespaces.
You can also create a restore point before dropping tables and use rman command to restore database to restore point 'rspname'
This is impossible! Firstly, rman run with "PLUS ARCHIVELOG" so your database is currently in archivelog mode. Secondly, you restore controlfile & database then perform "COMPLETE" recovery so at the time of complete - your test tables and users must be there.
If you would have followed the steps them you must see the tables. To avoid confusion use set until time or SCN or Time
SET UNTIL SCN <scn after object creation>;
SET UNTIL SEQUENCE <seq no after table creation>;
set until time <time after table creation>;
Also pls verify did you connect to right database
Here is the example
RMAN> restore controlfile from 'LOCATIN OF CONTROLFILE';
RMAN> ALTER DATABASE MOUNT;
RMAN>RUN
{allocate channel c1 device type disk;
allocate channel c2 device type disk;
set until time '2020-03-19:15:30:00';
restore database;
recover database;
ALTER DATABASE OPEN RESETLOGS;
}
I have two SQL Server 2008 R2 servers one for PROD and the other for DR. I am trying to add log shipping for a database called School.
Steps so far
Back up School database
Restore with database using the UI or using the following SQL statement i.e.
Restore database "School"
From disk ='t:\Data\School.bak'
with NoRecovery
The result is database is stuck in Restoring
If I restore the database with
Restore database "School"
From disk ='t:\Data\School.bak'
With recovery
The database restore completes but the log shipping fails.
I have deleted the database and recreated it again using
Restore database "School"
From disk ='t:\Data\School.bak'
With **NoRecovery**
but it is still stuck in Restoring state.
Is there a way that I can restore the database without having the database been stuck in the restoring state.
This seems like expected behavior to me. Am I misreading something?
After you've restored the database and any differential or required transaction log backups with the NORECOVERY option, you need to tell SQL Server you're done restoring files. The NORECOVERY option is specifically there to let you restore multiple files.
You should just need to run:
RESTORE DATABASE [School] WITH RECOVERY;
That will tell SQL Server you're done, and it will complete the restoration and it will no longer show up as restoring.
I have deleted the database and recreated it again using Restore database "School" from disk ='t:\Data\School.bak' with NoRecovery
you have to use below command as well,if you dont have any further logs
restore database databasename with recovery
some more info:
Restore with database using the UI or using the following SQL statement i.e.
next time try to issue restore statement using tsql,so that you can know status
restore database databasename from disk="path"
with stats=5
now if you want to know indepth details on where it is and what it is doing,you can use a trace flag like below
dbcc traceon(3004,3605,-1)
GO
restore database databasename from disk="path"
with stats=5
this logs output to errorlog like below
2008-01-23 08:59:56.26 spid52 RestoreDatabase: Database dbPerf_MAIN
2008-01-23 08:59:56.26 spid52 Opening backup set
2008-01-23 08:59:56.31 spid52 Restore: Configuration section loaded2008-01-23 08:59:56.31 spid52 Restore: Backup set is open
2008-01-23 08:59:56.31 spid52 Restore: Planning begins
2008-01-23 08:59:56.32 spid52 Halting FullText crawls on database dbPerf_MAIN
2008-01-23 08:59:56.32 spid52 Dismounting FullText catalogs
2008-01-23 08:59:56.32 spid52 X-locking database: dbPerf_MAIN
2008-01-23 08:59:56.32 spid52 Restore: Planning complete
2008-01-23 08:59:56.32 spid52 Restore: BeginRestore (offline) on dbPerf_MAIN
2008-01-23 08:59:56.40 spid52 Restore: PreparingContainers
2008-01-23 08:59:56.43 spid52 Restore: Containers are ready
For your current problem, you can look at event log as it will log current phase
Is there a way that I can restore the database without having the database been stuck in the restoring state.
you will have to get the spid of the backup and see the wait type and troubleshoot accordingly
select * from sys.dm_Exec_requests where sessionid=backupspid
I have two machine A and B and i want two setup standby database in machine B, so i have followed below steps..
Install oracle 11g express in machine A and same install in another
machine B for standby.
Enable Archive mode in both machine A and B.
Create TableSpace with name tbs_test on both machine.
Create user testuser on both machine & grant permission for dba.
In Machine A, i have create a table Tb_Employee and insert data
into table Tb_Employee on table space tbs_test.
Now take backup from some script on machine A and trying to
restore on machine B but not succeed due to some error mentioned in below statement.
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE;
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE
*
ERROR at line 1:
ORA-00283: recovery session canceled due to errors
ORA-19909: datafile 1 belongs to an orphan incarnation
ORA-01110: data file 1: 'C:\ORACLEXE\APP\ORACLE\ORADATA\XE\SYSTEM.DBF'
I have used following script to take backup(Full backup + Archive)
Step 1 Execute Begin Backup Script
conn / as sysdba;
alter system checkpoint;
alter tablespace SYSAUX begin backup;
alter tablespace SYSTEM begin backup;
alter tablespace TBS_Test begin backup;
exit;
Step 2 Copy SYSAUX.DBF, SYSTEM.DBF and TBS_Test.DBF files to backup directory
Step 3 create standby control file through execute following script
conn / as sysdba;
alter database backup controlfile to trace as 'C:\Backup\controlfile.txt' reuse;
alter database backup controlfile to 'C:\Backup\controlfile.ctl' reuse;
alter database create standby controlfile as 'C:\Backup\controlfile_standby.ctl';
exit
Step 4 copy stand by control file as Control.DBF into backup directory
Step 5 After copied files Execute End Backup Script
conn / as sysdba;
alter tablespace SYSAUX end backup;
alter tablespace SYSTEM end backup;
alter tablespace UNDOTBS1 end backup;
alter tablespace TBS_Test end backup;
exit;
Step 6 Execute script for Archive log
conn / as sysdba;
alter system checkpoint;
alter system archive log current;
disconnect;
exit;
Step 7 After execute script copy all archive files into backup directory("C:/Backup")
After just restore file into Machine B.
Not sure Oracle Express support standby (please consult the
documentation - as I remember Data Guard is licensed on top of
Enterprize Edition)
In order to configure standby it is not enough just to backup one
instance and restore to another - for this you will have to make
some more configurations (for example - to name instances according,
FORCE LOGGING, backup controlfile for standby, set LOG_ARCHIVE_DEST
parameters and many others, see documentation)
Your question is too "wide" we don't know what and how it has been done (put the scripts here), and in which order.
Currently Database is running on No-Archive Log mode. Can i Take only all datafiles (*.dbf) backup i.e. Excluding REDO and Control Files.
Also please let me know steps to restore the *.dbf file back in location.
If you want this database to be opened with simple startup command then you need redo and control files, since they are parts of the database.
However, if you don't have redo and control files in your cold backup then you will have to create control file with the script, usually generated with alter database backup controlfile to trace; and open the database with alter database open resetlogs - this command will create new redo logs.
Actually, you can open the database without the redo logs with alter database open resetlogs if this is a cold copy. The cold copy does not require recovery:
SQL> recover database until cancel using backup controlfile;
ORA-00279: change 6846169 generated at 01/20/2016 16:00:29 needed for thread 1
ORA-00289: suggestion : +DATA
ORA-00280: change 6846169 for thread 1 is in sequence #521
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
cancel
Media recovery cancelled.
SQL> alter database open resetlogs;
Database altered.
So no, you don't need redo logs with cold backups. The only requirement fot that is that the database have to be shutdown with immediate, not abort. So it would be consistent.
You also need the control files and red log files.
To restore, shutdown the database and copy the files back to their original locations. Then start the database.
Not recommended practice for a production environment. But I do this a lot with a test environment where I keep different version of the same database as cold backup sets.
We have a warm sql backup. full backup nightly, txn logs shipped every so often during the day and restored. I need to move the data files to another disk. These DB's are in a "warm backup" state (such that I can't unmark them as read-only - "Error 5063: Database '<dbname>' is in warm standby. A warm-standby database is read-only.
") and am worried about detaching and re-attaching.
How do we obtain the "warm backup" status after detach/attach operations are complete?
The only solution I know is to create a complete backup of your active database and restore this backup to a copy of the database in a 'warm backup' state. First create a backup from the active db:
backup database activedb to disk='somefile'
Then restore the backup on another sql server. If needed you can use the WITH REPLACE option to change the default storage directory
restore database warmbackup from disk='somefile'
with norecovery, replace ....
Now you can create backups of the logs and restore them to the warmbackup with the restore log statement.
It looks like you didn't complete the restore task , just do the restore task only for the TRANSACTOINAL LOG .Then it will be fine immediately when you finish that.