Version
Search
K
Links

Oracle DB's - Linux

How to backup Oracle 19c & 21c Databases Hosted on Linux Systems using Zmanda
Zmanda uses Oracle's RMAN and native OS tools to back up Oracle data files, control files, and archive logs.
There are two options to back up Oracle using Zmanda:
  1. 1.
    Use the default application to back up to a temporary local disk on the Amanda client and then to the Zmanda server. This method requires disk space on the client to store backup images temporarily. Archive logs will also be backed up.
  2. 2.
    Use RMAN to directly back up to the Zmanda server. Archive logs will also be backed up by default.

Preparing the Oracle Server for Backup and Restore 

Pre-requisites

  • Zmanda server and Oracle server are installed and licensed.
  • Linux Agent is installed on the Oracle Host

Steps

  1. 1.
    Ensure that the version of RMAN running matches the version of the Oracle server being backed up.
  2. 2.
    If you are using a different primary group for Oracle users on the Oracle server other than oinstall, configure it in the /etc/zmanda/aee5/zmc_user_dumptypes file on the Zmanda server using the syntax below:
define application-tool "app_amrman_user" {
property "ORACLE-GROUP" "dba"
}
  1. 3.
    Manually add entries to /etc/amanda/amanda-client.conf on the Zmanda client for the Oracle SIDs being backed up:
Use the following syntax for the entries:
property "<SID-List>-BACKUP-DIRECTORY" "Backup_path_on_client"
property "<SID-List>-ORACLE-SIDS" "SID_1" "[SID_2" ...]
property "<SID>-ORACLE-HOME" "Oracle_Home_Directory_for_SID"
property "<SID>-ORACLE-PATH" "Oracle_Path_for_SID"
property "<SID>-ORACLE-CONNECT-STRING" "Connect_string_for_SID"
Here's an example where the SID is ORCLCDB, the user is sys, and the password is zmanda:
property "ORCLCDB-BACKUP-DIRECTORY" "/tmp/zmanda_oracle/"
property "ORCLCDB-ORACLE-SIDS" "ORCLCDB"
property "ORCLCDB-ORACLE-HOME" "/opt/oracle/product/19c/dbhome_1/"
property "ORCLCDB-ORACLE-PATH" "/opt/oracle/product/19c/dbhome_1/bin"
property "ORCLCDB-ORACLE-CONNECT-STRING" "sys/zmanda@ORCLCDB"
  1. 4.
    Verifying RMAN Version Compatibility:
  • Ensure that the displayed RMAN version matches the version of the Oracle server being backed up.
  • Execute the following SQL query to check the RMAN version:
SQL> SELECT * FROM rcver;
VERSION ------------ 12.01.00.01
  1. 5.
    Prerequisites for Triggering Oracle on Linux Backups:
  • Before triggering backups, check the log mode of your Oracle database.
  • Oracle databases operate in either ARCHIVELOG or NOARCHIVELOG mode.
  1. 6.
    Checking Oracle Database Log Mode:
  • Execute the following SQL query to determine the log mode:
SELECT name, value
FROM v$parameter
WHERE name = 'log_archive_dest' OR name = 'log_archive_start';
This query examines two initialization parameters:
  • log_archive_dest: This parameter designates the destination for archived redo logs. It indicates that the database is operating in ARCHIVELOG mode.
  • log_archive_start: When set to TRUE, this parameter indicates that the database is in ARCHIVELOG mode.
  1. 7.
    Interpretation of Results:
  • If a row with name = 'log_archive_dest' and a non-null value is present, the database is in ARCHIVELOG mode.
  • If a row with name = 'log_archive_start' and the value is set to TRUE is present, the database is in ARCHIVELOG mode.
  • If neither row is present, the database is in NOARCHIVELOG mode.
  1. 8.
    Backup Conditions Based on Log Mode:
  • During ARCHIVELOG mode:
    • Oracle backups work only when the database is in READ-WRITE mode, open, and mounted.
  • During NOARCHIVELOG mode:
    • Oracle backups work only when the database is in READ-only mode, closed, and mounted.
  1. 9.
    Changing Database State:
Execute the following SQL query in the SQL prompt:
SQL> shutdown immediate;
SQL> startup mount;
Note: Use SQL> startup; to open the database. If you want the database to be closed but mounted, execute SQL> startup mount;.

Notes for the amanda-client.conf entries

  • Backup_path_on_client
Specifies where to store the backup image on the client. Backup images are removed after transfer to the Amanda server.
This directory requires sufficient space to hold a full backup of all SIDs selected for amoracle backups. In case of amrman backups, it is used for storing temporary command files and named pipes.
The Oracle user (the OS user through which Oracle is run) must be the owner of the client backup directory (the backup_path_on_client defined above).
The Oracle user's group should have read/write permissions on this backup directory, and the amandabackup user on the client OS should belong to the same group. For example, If the Oracle Database is run by the user oracle and the default group of the oracle user is oinstall, then the amandabackup user should be a member of the oinstall group. To ensure this, follow these steps (substituting your local Oracle GID for oinstall):
//Login to the Oracle server as root and type the following command:
id oracle
uid=501(oracle) gid=501(oinstall) groups=501(oinstall),502(dba)
//Determine the gid, and modify group membership for the amandabackup user:
usermod -G oinstall amandabackup
//Confirm that the change was made correctly
id amandabackup
uid=502(amandabackup) gid=6(disk) groups=6(disk),501(oinstall)
  • SID
The Oracle System Identifier corresponds to which databases to back up.
  • Oracle_Home_Directory_for_SID
Specify the home directory for the database to back up. This environment includes the location of installed product files, the PATH variable pointing to the binary files of installed products, registry entries, net service names, and program groups. Run the following command as the oracle user to output the path:
echo $ORACLE_HOME
  • Oracle_Path_for_SID
The path to Oracle binaries for the SID being backed up. The Oracle rman command must be located in this directory.
echo $ORACLE_HOME/lib
  • Connect_string_for_SID
This is the connection string to access the SID being backed up in the standard Oracle connect string format. Example:
oracle_user/oracle_user_password@SID
The Oracle user (oracle_user in the above example) used for connection should be sys with the sysdba role. If you want to use another Oracle user, sysdba privileges must be granted to the user.
  1. 10.
    Create a source in the Zmanda Management Console (ZMC)
  • Go to Sources > Add Source > Database
  • Under Type, select Oracle on Linux/Solaris
  • Fill out the Hostname and SID Listname fields
  • Select the Backup Set(s) to associate the source with
  • In the Advanced menu, you can choose to override the default Amanda Backup Client Application. Option 1 (described at the top of this page) is the default. Option 2 uses RMAN to send the backed-up data directly to storage. Please note that Option 2 requires additional restore steps which are covered below.
  • Configure Encryption, Compression, and/or Deduplication as desired, and click SAVE
  1. 11.
    Click on the Check-Host icon and wait for the green icon to appear. If you don't see a green icon, double-check the error message by clicking on the icon, and then double-check your entries in the amanda-client.conf file
Make sure that all Oracle databases selected for backup are mounted and open. For restoration, the databases should be mounted but closed. 
  1. 12.
    Once the Check Host is completed, you can run a backup using the normal steps.

Performing Oracle Restores using the Zmanda Management Console and RMAN 

Restoration involves two main steps:
  1. 1.
    Use the Zmanda Management Console to restore the files to a directory you create on the client machine for that purpose. Additional disk space is required for restoration on the Destination Host.
  2. 2.
    Use the Oracle RMAN utility to apply the restored backup to the Oracle server.

Step 1: Use the ZMC to restore to a directory on the client 

  1. 1.
    Log on to the client machine where the Oracle databases are being restored. Create a directory on a file system that has sufficient space to store the restored files.
  2. 2.
    Use the ZMC Restore What page to decide which backups to restore as shown below. Enter the backup date, Alias/Directory Path (BETSOL in the example below)  and Oracle server name (192.168.53.89 in the example below) used during backup.
In the newly created directory, use the ZMC Restore pages to restore the Oracle backup, specifying the directory you created in the previous step as the Destination Directory on the Restore Where page.
  1. 3.
    Check the file ownerships of the restored database files. You may have to change the file/group ownership to the Oracle user/group (Example: oracle/oinstall) before trying to use the RMAN steps described in the next two sections to recover the database.

Step 2: Restore procedure if Option 1 was used for backup 

If RMAN was specified as the Custom Application on the Sources page, you will need to make RMAN aware of the Amanda media before a restore can be completed. After restoring from the ZMC as described above, follow these steps:
  1. 1.
    Login to the Oracle Server:
  • Log in to the Oracle server as a user who owns the Oracle instance.
Example: If the username is oracle, execute the following command:
su – oracle
  1. 2.
    Connect to the Database via RMAN:
  • Set the Oracle SID and connect to the database using RMAN.
set ORACLE_SID=<your_database_sid>
rman target /
  1. 3.
    Alter the Database to nomount:
  • Shutdown the database immediately and start it in nomount mode.
shutdown immediate;
startup nomount;
  1. 4.
    Configure SBT_TAPE for Zmanda's AMML Library:
  • From the RMAN prompt, configure SBT_TAPE to use Zmanda's AMML library. Adjust the SBT_LIBRARY path based on your client architecture.
RUN
{
ALLOCATE CHANNEL CH1 DEVICE TYPE 'SBT_TAPE' PARMS 'SBT_LIBRARY=/usr/lib64/amanda/application/ammml.so,ENV=(BACKUP_DIR=/home/subhadipmandal/oracle_test_restore)';
}
Note: In the above illustration, the Oracle backup images were recovered to the /home/subhadipmandal/oracle_test_restore directory using ZMC. The instance below indicates the location of ammml.so on a 64-bit client. If you are employing a 32-bit client, ensure that the SBT_LIBRARY is configured to /usr/lib/amanda/application/ammml.so.
  • If restoring the control file is required, include the following command in the above RUN block:
RESTORE CONTROLFILE FROM 'c-<your_restored_control_file>';
Note: Replace c-<your_restored_control_file> with the control file name in the restore directory. The file commencing with "c-" in the restore directory identifies the control file.
  1. 5.
    Mount Back the Database:
alter database mount;
  1. 6.
    Catalog Extracted Backup Pieces:
  • Catalog all extracted backup pieces. If backing up table space and archive logs separately, extract components in a directory before cataloging.
CATALOG DEVICE TYPE 'SBT_TAPE' BACKUPPIECE '/path/to/backup_piece';
or  a RUN {} block can be written for the same. For example:
RUN
{
CATALOG DEVICE TYPE 'SBT_TAPE' BACKUPPIECE
'/home/oracle_restore/4skbv4ic_1_1.17';
CATALOG DEVICE TYPE 'SBT_TAPE' BACKUPPIECE
'/home/oracle_restore/4tkbv4k2_1_1.17';
CATALOG DEVICE TYPE 'SBT_TAPE' BACKUPPIECE
'/home/oracle_restore/4ukbv4ln_1_1.17';
CATALOG DEVICE TYPE 'SBT_TAPE' BACKUPPIECE
'/home/oracle_restore/4vkbv4nc_1_1.17';
CATALOG DEVICE TYPE 'SBT_TAPE' BACKUPPIECE
'/home/oracle_restore/50kbv4p2_1_1.17';
CATALOG DEVICE TYPE 'SBT_TAPE' BACKUPPIECE
'/home/oracle_restore/51kbv4qn_1_1.17';
CATALOG DEVICE TYPE 'SBT_TAPE' BACKUPPIECE
'/home/oracle_restore/52kbv4sc_1_1.17';
CATALOG DEVICE TYPE 'SBT_TAPE' BACKUPPIECE
'/home/oracle_restore/53kbv4u2_1_1.17';
CATALOG DEVICE TYPE 'SBT_TAPE' BACKUPPIECE
'/home/oracle_restore/54kbv4vo_1_1.17';
CATALOG DEVICE TYPE 'SBT_TAPE' BACKUPPIECE
'/home/oracle_restore/55kbv57j_1_1.17';
CATALOG DEVICE TYPE 'SBT_TAPE' BACKUPPIECE
'/home/oracle_restore/56kbv581_1_1.17';
}
Verify all cataloged backup pieces using the list backup RMAN command.
RMAN> list backup;
List of Backup Sets
===================
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
9       Full    Unknown    SBT_TAPE    00:00:26     17-DEC-09
BP Key: 15   Status: AVAILABLE  Compressed: NO  Tag: TAG20091217T043756
Handle: /home/oracle_restore/system_<wbr/>tbs/09l13rl4_1_1.17   Media:
List of Datafiles in backup set 9
File LV Type Ckp SCN    Ckp Time  Name
---- -- ---- ---------- --------- ----
1       Full 675339     17-DEC-09 /u02/oradata/db10g/system01.<wbr/>dbf
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
10      Full    Unknown    SBT_TAPE    00:00:02     17-DEC-09
BP Key: 16   Status: AVAILABLE  Compressed: NO  Tag: TAG20091217T043756
Handle: /home/oracle_restore/system_<wbr/>tbs/0al13rm8_1_1.17   Media:
Control File Included: Ckp SCN: 675370       Ckp time: 17-DEC-09
SPFILE Included: Modification time: 16-DEC-09
  • RMAN is now configured to complete the Oracle recovery as described below.
  1. 7.
    Restore the Database Files:
restore database;
  • This command extracts dbf files and other db-related files if necessary. Recovery will occur with the next command.
  1. 8.
    Recover the Database:
recover database;
  • This command applies available archive log files in the archive directory, searching for available archive sequence numbers and applying them to the database.
  1. 9.
    Open the Database:
  • Open the database again by resetting the log sequence number to 1.
alter database open resetlogs;
The recovery process is now complete!

Step 2: Restore procedure if Option 2 was used for backup

Before running RMAN, you may want to read "Using RMAN for Restores" from the Oracle documentation".
Start RMAN for all the databases being restored. These databases should be mounted but closed. Execute RMAN RESTORE commands to restore from the directory created above. Execute the RMAN RECOVER command after the RESTORE is successful. When you are done, you can delete the directory you created for the recovery.
RMAN command example to restore and recover the deleted data file from one of the table spaces.
RMAN> restore datafile '/u02/oradata/ORCL/datafile/zmanda_tsp.dfb';
Starting restore at 03-MAR-09
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=130 device type=DISK
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: SID=128 device type=SBT_TAPE
channel ORA_SBT_TAPE_1: AMANDA MEDIA MANAGEMENT LIBRARY FOR ORACLE
channel ORA_SBT_TAPE_1: starting datafile backup set restore
channel ORA_SBT_TAPE_1: specifying datafile(s) to restore from backup set
channel ORA_SBT_TAPE_1: restoring datafile 00005 to
/u02/oradata/ORCL/datafile/zmanda_tsp.dfb
channel ORA_SBT_TAPE_1: reading from backup piece 5kk8v9pt_1_1
channel ORA_SBT_TAPE_1: errors found reading piece handle=5kk8v9pt_1_1
channel ORA_SBT_TAPE_1: failover to piece
handle=/u02/oracle_bkp_test/restore/5kk8v9pt_1_1
tag=TAG20090303T043820
channel ORA_SBT_TAPE_1: restored backup piece 1
channel ORA_SBT_TAPE_1: restore complete, elapsed time: 00:00:01
Finished restore at 03-MAR-09
RMAN> recover datafile '/u02/oradata/ORCL/datafile/zmanda_tsp.dfb';
Starting recover at 03-MAR-09
using channel ORA_DISK_1
using channel ORA_SBT_TAPE_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 03-MAR-20
Switch online the table space that had missing data files or corrupted data files. Oracle will perform table space recovery.