# Renseigner les variables ci-dessous avec les valeurs appropriees a votre environnnement avant de lancer le script

$JAVA_HOME =

$DBFOLDERPATH =
$ZIPFOLDER =
$ZIPNAME =
$DPDUMPFOLDERPATH =

$SQLSCRIPTPATH =

$ORACLEADMINACCOUNTNAME = "SYSTEM"
$ORACLEADMINACCOUNTPWD = "SYSTEM"
$ORACLEADMINACCOUNTPWDFILE =
$DPDUMPONLY = "false"
$SAVEWEBAPPS = "true"
$SAVEJRE = "true"

$DATENOW = Get-Date -Format "yyyyMMdd-HHmmss"
$ZIPFILEPATH = "$ZIPFOLDER\$ZIPNAME-$DATENOW.zip"

if ($PSVersionTable.PSVersion.Major -lt 3) 
{
	$PSScriptRoot = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
}

$LIB = "$PSScriptRoot\DBManagerCmdLine.jar"
$JAVA = "'$JAVA_HOME\bin\java.exe'"
$CMD = "$JAVA -cp '$LIB' db.manager.cmd.DBSaveCmd"

$CMD = "$CMD -dbfolderpath '$DBFOLDERPATH'"
$CMD = "$CMD -zipfilepath '$ZIPFILEPATH'"
$CMD = "$CMD -dpdumpfolderpath '$DPDUMPFOLDERPATH'"
$CMD = "$CMD -oracleadminaccountname $ORACLEADMINACCOUNTNAME"
# Password directly written in script (not safe)
$CMD = "$CMD -oracleadminaccountpwd $ORACLEADMINACCOUNTPWD"
# or use encrypted password in file (see pwd.ps1)
#$CMD="$CMD -oracleadminaccountpwdfile $ORACLEADMINACCOUNTPWDFILE"
#$CMD = "$CMD -dpdumponly $DPDUMPONLY"
#$CMD = "$CMD -savewebapps $SAVEWEBAPPS"
#$CMD = "$CMD -savejre $SAVEJRE"
#$CMD="$CMD -sqlscriptpath '$SQLSCRIPTPATH'"

Invoke-Expression "& $CMD"

exit $LASTEXITCODE
