Bash Example: Backup Multiple Oracle User Schema

Contents

  1. Example
  2. References
 

Example

#!/bin/sh
 
backup_dir=/backup/db
db_sid=orcl
 
DECLARE -A usrs
usrs[scott]=tiger
usrs[hr]=hr
 
curr_ts=`date +"%m-%d-%y_%H-%M-%S"`
curr_backup_dir=${backup_dir}/${curr_ts}
mkdir -p ${curr_backup_dir}
 
FOR k IN "${!usrs[@]}"
do
	echo "Backing up ${k}..."
	expcmd="exp ${k}/${usrs[$k]}@${db_sid} owner=${k} grants=y rows=y compress=y file=${curr_backup_dir}/${k}.exp log=${curr_backup_dir}/${k}.log &"
	echo "export command is: ${expcmd}"
	echo "done."
	echo ""
done
 
echo "All done."

References

* Bash Associative Arrays

 
This entry was posted in oracle, shell and tagged , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


*

This site uses Akismet to reduce spam. Learn how your comment data is processed.