Bash Script for Automation of Full Oracle Database Export

(Insert blurb here, too lazy to type a description today. Read the variables and replace values as needed. It’s pretty straightforward.)

#!/bin/bash

#Linux - Put your Dump File in this Directory 
VARIABLE_DATABASE_DIR="/DatabaseDir"

#Windows - Put your Dump File in this Directory 
#VARIABLE_DATABASE_DIR="C:/DatabaseDir"

VARIABLE_DATABASE_DUMP="myDump.dmp"
VARIABLE_PDB="MyPDB"
VARIABLE_SYS_ACCOUNT_PASSWORD="password"
VARIABLE_SYSTEM_ACCOUNT_PASSWORD="password"
VARIABLE_SCRIPT_TEMP_PATH=$(mktemp)
VARIABLE_SCRIPT_TEMP_PATH+='.sql'

echo "Generating SQL Script under $VARIABLE_SCRIPT_TEMP_PATH"

echo "/* Begin SQL Script */

alter session set container=$VARIABLE_PDB

CREATE OR REPLACE DIRECTORY DatabaseDir AS '$VARIABLE_DATABASE_DIR';

alter session set \"_ORACLE_SCRIPT\"=true;

alter pluggable database $VARIABLE_PDB close immediate;

alter pluggable database $VARIABLE_PDB open upgrade;

alter session set container=$VARIABLE_PDB;

alter system set MAX_STRING_SIZE=extended;

@?/rdbms/admin/utl32k.sql

alter pluggable database $VARIABLE_PDB close immediate;

alter pluggable database $VARIABLE_PDB open;

@?/rdbms/admin/utlrp.sql

alter session set \"_ORACLE_SCRIPT\"=true;

alter session set container=$VARIABLE_PDB;

CREATE OR REPLACE DIRECTORY DatabaseDir AS '$VARIABLE_DATABASE_DIR';

commit;

/* End SQL Script */" >> $VARIABLE_SCRIPT_TEMP_PATH

echo "EXIT;" >> $VARIABLE_SCRIPT_TEMP_PATH

VARIABLE_TIMESTAMP=$(date "+%Y-%m-%d_%H_%M_%S")
VARIABLE_LOG_FILE="$VARIABLE_DATABASE_DUMP_"
VARIABLE_LOG_FILE+=$VARIABLE_TIMESTAMP

echo "##############################################" 
echo "#### BEGIN EXECUTION OF SQL PLUS COMMANDS ####"
echo "##############################################" 
echo ""

VARIABLE_LOG_FILE_SQLPLUS=$VARIABLE_LOG_FILE.sqlplus.log

sqlplus "sys/$VARIABLE_SYS_ACCOUNT_PASSWORD@$VARIABLE_PDB as sysdba" @$VARIABLE_SCRIPT_TEMP_PATH >> $VARIABLE_LOG_FILE_SQLPLUS

echo ""
echo "#########################################" 
echo "#### BEGIN EXECUTION OF DUMP COMMAND ####" 
echo "#########################################" 
echo ""

VARIABLE_LOG_FILE_EXPDP=$VARIABLE_LOG_FILE.expdp.log

expdp "system/$VARIABLE_SYSTEM_ACCOUNT_PASSWORD@$VARIABLE_PDB" full=y directory=DatabaseDir dumpfile=$VARIABLE_DATABASE_DUMP logfile="$VARIABLE_LOG_FILE_EXPDP"

pKill Function for Git-Bash

I constantly find myself accidentally typing pkill in git-bash and then it not being supported because, you know, it’s not a windows command.

So I quickly wrote a function for it and put it in the .bashrc file under my users home directory.

Below is the code snippet – .bashrc:

function pkill(){
	wmic Path win32_process Where "CommandLine Like '%$2%'" Call Terminate
}

Invoked like this:

Restart Docker Daemon

FYI for myself for later…

Restarting Docker Daemon in DockerToolbox Version (This was annoying to find):

sudo /etc/init.d/docker restart

Restarting Docker Daemon in a Normal Docker distribution:

sudo service docker stop
sudo service docker start

API Bookmark Creation Program – Utilizing PowerShell

Today I created something pretty cool.

So basically, I analyzed the weird broken format of bookmark HTML exports and created a program that you can feed endpoints so it will generate your own basic API tool for debugging common endpoints.

Basically you feed it Dev/UAT/Prod strings for the Frontend Application URL and the Backend Webservices URL and it generates a nested folder structure of bookmarks based on the Actions and Endpoints given.

Below is the link to the Github repo and an example picture:

https://github.com/qwertycody/ApiBookmarkGenerationTool

Packages for Xfce Desktop

Weirdly enough this package group isn’t available on all distros of Linux so I’m taking a note of the required packages so I can manually install them.

Raw Output from Linux:

[root@ae0112599368 /]# yum groupinfo Xfce
Loaded plugins: fastestmirror, ovl
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
 * base: centos.vwtonline.net
 * epel: mirror.cogentco.com
 * extras: centos.vwtonline.net
 * updates: mirror.compevo.com

Group: Xfce
 Group-Id: xfce-desktop
 Description: A lightweight desktop environment that works well on low end machines.
 Mandatory Packages:
   +Thunar
   +xfce4-panel
   +xfce4-session
   +xfce4-settings
   +xfconf
   +xfdesktop
   +xfwm4
 Default Packages:
   +NetworkManager-gnome
   +gdm
   +leafpad
   +openssh-askpass
   +orage
   +polkit-gnome
   +thunar-archive-plugin
   +thunar-volman
   +tumbler
   +xfce4-appfinder
   +xfce4-icon-theme
   +xfce4-power-manager
   +xfce4-pulseaudio-plugin
   +xfce4-session-engines
   +xfce4-terminal
   +xfwm4-theme-nodoka
 Optional Packages:
   xfwm4-themes
 Conditional Packages:
   +pinentry-gtk

Yum Command:

yum install -y Thunar xfce4-panel xfce4-session xfce4-settings xfconf xfdesktop xfwm4 NetworkManager-gnome gdm leafpad openssh-askpass orage polkit-gnome thunar-archive-plugin thunar-volman tumbler xfce4-appfinder xfce4-icon-theme xfce4-power-manager xfce4-pulseaudio-plugin xfce4-session-engines xfce4-terminal xfwm4-theme-nodoka