Backing Up and Restoring Data > Reporting Database Export Backups
  
Version 10.0.01
Reporting Database Export Backups
This method is the preferred method of ensuring that your database is backed up on a regular basis. This is a two-step process:
Customizing the Export Script
Scheduling the Export Job (Linux) or Scheduling the Export Job (Windows)
Customizing the Export Script
Beginning with Hitachi Storage Viewer 8, Feature Pack Three (8.3.00), a template is provided for automating the database backup process. This template needs to be copied and then customized for your installation.
1. Locate the script template:
Linux: opt/aptare/database/tools/export_database_template.sh
Windows: C:\opt\oracle\database\tools\export_database_template.bat
2. Before customizing the backup script, export_database_template.sh|bat, first copy it and then rename it to something like: export_database.sh|bat
This preserves the template file, which gets overwritten during a Portal upgrade, and provides a file for customization and execution: export_database.sh|bat
3. Refer to the relevant steps to customize the script:
Linux: Customize the Script
Windows: Customize the Script
4. Refer to the relevant steps to schedule the task:
Scheduling the Export Job (Linux)
Scheduling the Export Job (Windows)
Important! It is critical that the database export file is included in your file system backup policy so that, in the event of a disaster, you can restore and then import the export file.
Linux: Customize the Script
In the export_database.sh script:
Replace customername with your relevant company name.
Replace /ora_exports with a directory that is included in your file system backup policy.
 
#!/bin/sh
# The following script is the Hitachi Storage Viewer database export script for customername
 
NOTIFY_LIST="support@customername.com"
FILENAME=customername_scdb.exp_`date +%m%d%g`
LOGFILENAME=ccustomername_scdb_`date +%m%d%g`.log
ORACLE_HOME=/opt/aptare/oracle
ORACLE_SID=scdb
export ORACLE_HOME ORACLE_SID
 
# Set the export directory
PATHNAME=/ora_exports
 
# Export the database
/opt/aptare/oracle/bin/exp parfile=/opt/aptare/database/tools/export_scdb.par file=$PATHNAME/$FILENAME log=$PATHNAME/$LOGFILENAME
 
if [ $? -eq 0 ]; then
if [ -f $PATHNAME/$FILENAME]; then
if [ -f "$PATHNAME/$FILENAME.gz" ]; then
rm -f "$PATHNAME/$FILENAME.gz"
fi
echo "Done with export"
fi
else
echo `date` "Problem with export on customername"
echo "Problem with export on customername" | mail -s "customername export problem" $NOTIFY_LIST
exit 1
fi
 
gzip -f "$PATHNAME/$FILENAME"
 
exit 0
Windows: Customize the Script
In the export_database.bat script:
Replace customername with your relevant company name.
Replace C:\tmp with a directory included in your file system backup policy.
Customize the mailto line to be compatible with your environment.
If you choose to use a tool other than 7-Zip, change the software used to zip the file.
@echo off
REM The following script is the Hitachi Storage Viewer database export script for customername
 
SET NOTIFY_LIST=support@customername.com
 
FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B
FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B
FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO SET dd=%%B
FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('echo %CDATE%') DO SET yyyy=%%B
SET date=%mm%%dd%%yyyy%
set date=%date: =%
REM Set the export directory
SET PATHNAME=C:\tmp
SET FILENAME=aptare_scdb.exp_%date%
SET LOGFILENAME=customername_scdb_`date +%m%d%g`.log
SET ZIP_FILENAME=%PATHNAME%\%FILENAME%.zip
 
REM Export the database
c:\opt\oracle\bin\exp parfile=c:\opt\oracle\database\tools\export_scdb.par file=%PATHNAME%\%FILENAME% log=$PATHNAME\$LOGFILENAME
ECHO %ZIP_FILENAME%
IF ERRORLEVEL 0 (
IF exist %PATHNAME%\%FILENAME% (
IF exist %ZIP_FILENAME% (
DEL %ZIP_FILENAME%
echo Done with export
)
)
)
IF NOT ERRORLEVEL 0 (
echo %date% "Problem with export on customername"
START mailto:%NOTIFY_LIST%?subject=20customername%%20export%%20problemˆ&body=Problem%%20with%%20export%%20on%%20customername
)
 
"c:\Program Files\7-Zip\7z.exe" a %ZIP_FILENAME% %PATHNAME%\%FILENAME%
 
IF exist %ZIP_FILENAME% (
IF exist %PATHNAME%\%FILENAME% (
DEL %PATHNAME%\%FILENAME%
)
)
Scheduling the Export Job (Linux)
1. Switch to user aptare.
su - aptare
2. Edit or create the crontab file.
crontab -e
3. Using the following diagram, specify the database export schedule.
Example:
04 15 * * * /opt/aptare/utils/export_database.sh 2>&1 >>/tmp/database_export.log
 
4. Verify the newly scheduled job:
crontab -l
Scheduling the Export Job (Windows)
1. Start > Programs > Accessories > System Tools > Task Scheduler
2. Create a new task in the Task Scheduler by specifying the schedule and the script to be run:
c:\opt\aptare\utils\export_database.bat