Powershell Oracle Db Backup

Hi all,

I thought I would share with you this quick Powershell script I created to Export an oracle database, 7Zip it and then upload it to AmazonS3

Export.ps1

param([String]$dumpname=(get-date -format dd-MM-yyyy))
          
Set-Alias sz "$env:ProgramFiles\7-Zip\7z.exe"
          
expdp <myDbUser>/<mypasswd>
   DIRECTORY=dmpdir DUMPFILE=$dumpname.dmp
   LOGFILE=$dumpname.log
         
sz a -mx "$dumpname.7z" "$dumpname.*"
Write-S3Object -bucket "company-ps"
   -profilename brian.keating
   -file "$dumpname.7z" -key "customer/dbdumps/$dumpname.7z"
remove-item "$dumpname.dmp"
remove-item "$dumpname.log"

       

 

How it works:

It uses the current date as the dumpname variable (unless specified as a parameter to the script)

It uses Oracle DbPump to export the database (assumes 7-Zip is installed in %\program files\)

It then writes the 7z file to AWS S3

Finally it removes the dump and log files.

AWS Powershell

ASW Powershell is installed on this server and I have already set a profile “brian.keating” with the following command.

set-awscredentials –AccessKey <ACCESSKEY> –SecretKey <KEY> -storeAs brian.keating

 

Trivia

The server in this case is running in AWS, the 7zipped db is about 4Gb, and it uploads to S3 in about 30seconds (nice!)

Comments are closed

Recent Tweets

Note: For Customization and Configuration, CheckOut Recent Tweets Documentation

Calendar

<<  July 2017  >>
MoTuWeThFrSaSu
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

View posts in large calendar

Month List