Showing posts with label Backup & Recovery. Show all posts
Showing posts with label Backup & Recovery. Show all posts

Oracle Data Pump Backup Day Wise

#!/bin/sh

export ORACLE_BASE=/u01/oracle
export ORACLE_HOME=$ORACLE_BASE/product/12.2.0/dbhome_1
export BKP_HOME=$ORACLE_BASE/data_pump
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID = oratrg

echo 'Exporting Full Oracle Database Backup....'

expdp hr/hr directory=<directory name> dumpfile=FULL-$(date +%A).dmp logfile=FULL-$(date +%A).log full=y

tar -cvzf $BKP_HOME/FULL-$(date +%A).tar.gz $BKP_HOME/FULL-$(date +%A).dmp
cat $BKP_HOME/FULL-$(date +%A).log

echo 'Transferring Oracle Export Dump file to Remote location ....'

cd $BKP_HOME
smbclient //<Remote_Location>/D$ -U <Windows Domain Name>/<User>%<Password-c "put FULL-$(date +%A).log"
smbclient //<Remote_Location>/D$ -U <Windows Domain Name>/<User>%<Password -c "put FULL-$(date +%A).tar.gz"

Export Database using smbclient

#!/bin/sh

export ORACLE_BASE=/u01/oracle
export ORACLE_HOME=$ORACLE_BASE/product/12.2.0/dbhome_1
export BKP_HOME=$ORACLE_BASE/data_pump
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID = oratrg

echo 'Exporting Full Oracle Database Backup....'

expdp hr/hr directory=data_pump dumpfile=full.dmp logfile=full.log reuse_dumpfiles=y full=y

tar -cvzf $BKP_HOME/full.tar.gz $BKP_HOME/full.dmp
cat $BKP_HOME/full.log

echo 'Transferring Oracle Export Dump file to Remote location ....'

cd $BKP_HOME
smbclient //<Remote_Location>/D$ -U <Windows Domain Name>/<User>%<Password -c "put full.dmp"
smbclient //<Remote_Location>/D$ -U <Windows Domain Name>/<User>%<Password-c "put full.log"
smbclient //<Remote_Location>/D$ -U <Windows Domain Name>/<User>%<Password -c "put full.tar.gz"

What is the difference between restoring and recovering?

Restoring involves copying backup files from secondary storage (backup media) to disk.

This can be done to replace damaged files or to copy/move a database to a new location.

Recovery is the process of applying redo log to the database to roll it forward.

One can roll – forward until a specific point – in – time (before the disaster occurred) or roll – forward until the last transaction recorded in the log files.

SQL> connect SYS as SYSDBA
SQL> RECOVER DATABASE UNTIL TIME '2016 – 03 – 06:16:00:00' USING BACKUP CONTROLFILE; 

What strategies are available for backing – up an Oracle database?

The following methods are valid for backing – up an Oracle database 

Export / Import – Exports are "logical" database backups in that they extract logical definitions and data from the database to a file.

Cold or Offline Backups – Shutdown the database and backup up all data, log and control files

Hot or Online Backups – If the databases are available and in ARCHIVELOG mode, set the tablespaces into backup mode and backup their files

Also remember to back up the control files and archived redo log files.

RMAN Backups – While the database is Offline or Online use "RMAN" utility to back up database

Oracle DataPump - ExpDp

It is advisable to use more than one of these methods to backup your database.

For example, if you choose to do Online database backups; also cover yourself by doing database exports.

Also test all backup and recovery scenarios carefully. It is better to be safe than sorry. 

Regardless of your strategy, also remember to backup all required software libraries, parameter files, password files etc.


If your database is in ARCHIVELOG mode, you also need to backup archived log files.

Why and when should one backup database?

Backup and recovery is one of the most important aspects of a DBA job. 
If you lose your company's data, you could very well lose your job.
Hardware and software can always be replaced, but your data may be irreplaceable!
Normally one would schedule a hierarchy of daily, weekly and monthly backups, however consult with your users before deciding on a backup schedule.
  1. Backup frequency normally depends on the following factors
  2. Rate of data change/ transaction rate
  3. Database availability/ Can you shutdown for cold backups? 
  4. Criticality of the data/ Value of the data to the company
  5. Read – only table space needs backing up just once right after you make it read only
  6. If you are running in archivelog mode you can backup parts of a database over an extended cycle of days
  7. If archive logging is enabled one needs to backup archived log files timeously to prevent database freezes
Carefully plan backup retention periods. 
Ensure enough backup media (tapes) are available and that old backups are expired in – time to make media available for new backups.
Offsite vaulting is also highly recommended.
Frequently test your ability to recover and document all possible scenarios.
Remember, it's the little things that will get you. Most failed recoveries are a result of organizational errors and miscommunications

How to fix: ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)

Open your terminal and type mysql -u root -p Enter your password. Hopefully your MySQL is logged in now.