Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions deploy/data-archive/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Database Archiving Configuration

This configuration file is used for setting up database connections and defining archiving parameters. Please follow the guidelines below to fill in the required information.

## Database Connections

### Archive Database Connection (archive_db)

- `db_name`: Name of the archive database.
- `host`: Destination host for the archive database.
- `port`: Port number for the archive database connection.
- `su_user`: Superuser for the archive database.
- `su_user_pwd`: Password for the superuser.
- `db_pwd`: Password for the archive database.
- `archivehost`: Destination host for the archive database.
- `archiveport`: Port number for the archive database connection.
- `archiveuname`: Archive database username.
- `archive_dbname`: Archive database name.
- `archive_schemaname`: Archive schema name.
- `archive_db_password`: Password for the archive database.

### Source Database Connections (source_db)

For each source database (audit, credential, esignet, ida, idrepo, kernel, master, pms, prereg, regprc, resident), provide the following information:

- `source_<database>_host`: Source database host.
- `source_<database>_port`: Port number for the source database connection.
- `source_<database>_uname`: Source database username.
- `source_<database>_dbname`: Source database name.
- `source_<database>_schemaname`: Source schema name.
- `source_<database>_db_pass`: Password for the source database.

- `provide_db_names_to_archive`: Comma-separated list of database names to archive (e.g., "AUDIT,CREDENTIAL,IDA,.....").(in CAPS)


## Container Volume Path
container_volume_path: Path where JSON files containing information about all databases will be stored

## Archiving Information (all_db_tables_info)

For each database, specify tables_info with details for archiving. Example:

```yaml
audit:
tables_info:
- source_table: "app_audit_log"
archive_table: "mosip_audit_app_audit_log"
id_column: "log_id"
date_column: "log_dtimes"
retention_days: 30
operation_type: "archive_delete"

source_table: Name of the table in the source database.
archive_table: Name of the table in the archive database.
id_column: Column representing the unique identifier.
date_column: Column representing the date of the record.
retention_days: Number of days to retain the archived data.
operation_type: Type of operation for archiving (e.g., archive_delete, delete, none).
- Delete: Delete records from the source table.
- Archive and Delete: Archive records to an archive table and then delete them from the source table.
- Archive (No Delete): Archive records to an archive table without deleting them from the source table.
- None: Skip archival for the specified table.
30 changes: 30 additions & 0 deletions deploy/data-archive/delete.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
# Uninstalls data-archive
## Usage: ./delete.sh [kubeconfig]

if [ $# -ge 1 ] ; then
export KUBECONFIG=$1
fi

function deleting_data-archive() {
NS=data-archive
while true; do
read -p "Are you sure you want to delete data-archive helm charts?(Y/n) " yn
if [ $yn = "Y" ]
then
helm -n $NS delete data-archive
break
else
break
fi
done
return 0
}

# set commands for error handling.
set -e
set -o errexit ## set -e : exit the script if any statement returns a non-true return value
set -o nounset ## set -u : exit the script if you try to use an uninitialised variable
set -o errtrace # trace ERR through 'time command' and other functions
set -o pipefail # trace ERR through pipes
deleting_data-archive # calling function
82 changes: 82 additions & 0 deletions deploy/data-archive/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/bin/bash
# Installs data-archive
## Usage: ./install.sh [kubeconfig]

if [ $# -ge 1 ]; then
export KUBECONFIG=$1
fi

NS=data-archive
CHART_VERSION=0.0.1-develop

echo Create $NS namespace
kubectl create ns $NS

function installing_data-archive() {
echo Updating repos
helm repo add mosip https://mosip.github.io/mosip-helm
helm repo update

read -p "Is values.yaml for data-archive chart set correctly as part of Pre-requisites?(Y/n) " yn;
if [ "$yn" != "Y" ]; then
echo "ERROR: values.yaml not set correctly; EXITING;";
exit 1;
fi

read -p "Please enter the time(hr) to run the cronjob every day (time: 0-23) : " time
if [ -z "$time" ]; then
echo "ERROR: Time cannot be empty; EXITING;";
exit 1;
fi
if ! [ $time -eq $time ] 2>/dev/null; then
echo "ERROR: Time $time is not a number; EXITING;";
exit 1;
fi
if [ $time -gt 23 ] || [ $time -lt 0 ]; then
echo "ERROR: Time should be in range ( 0-23 ); EXITING;";
exit 1;
fi

read -p "Is archival running for sandbox installation? (Y/N): " archival_running
if [ "$archival_running" == "Y" ]; then
echo "Sandbox installation selected. This will use superuser PostgreSQL secrets for creating archivedb."
super_user_password=$(kubectl get secret --namespace postgres postgres-postgresql -o jsonpath={.data.postgres-password} | base64 --decode)
echo "Common secrets will be used as passwords for all the db users."
db_common_password=$(kubectl get secret --namespace postgres db-common-secrets -o jsonpath={.data.db-dbuser-password} | base64 --decode)
set_db_pwd="--set databases.archive_db.su_user_pwd=$super_user_password \
--set databases.source_db.source_audit_db_pass=$db_common_password \
--set databases.source_db.source_credential_db_pass=$db_common_password \
--set databases.source_db.source_esignet_db_pass=$db_common_password \
--set databases.source_db.source_ida_db_pass=$db_common_password \
--set databases.source_db.source_idrepo_db_pass=$db_common_password \
--set databases.source_db.source_kernel_db_pass=$db_common_password \
--set databases.source_db.source_master_db_pass=$db_common_password \
--set databases.source_db.source_pms_db_pass=$db_common_password \
--set databases.source_db.source_prereg_db_pass=$db_common_password \
--set databases.source_db.source_regprc_db_pass=$db_common_password \
--set databases.source_db.source_resident_db_pass=$db_common_password \
--set databases.archive_db.db_pwd=$db_common_password \
--set databases.archive_db.archive_db_password=$db_common_password"

elif [ "$archival_running" == "N" ]; then
echo "Other installation selected.This will Use individual secrets for db passwords from values.yaml"
set_db_pwd=""
else
echo "Incorrect input; EXITING;"
exit 1;
fi

# Install data-archive
helm -n $NS install data-archive mosip/data-archive --set crontime="0 $time * * *" -f values.yaml $set_db_pwd --version $CHART_VERSION

echo Installed data-archive
return 0
}

# set commands for error handling.
set -e
set -o errexit ## set -e : exit the script if any statement returns a non-true return value
set -o nounset ## set -u : exit the script if you try to use an uninitialised variable
set -o errtrace # trace ERR through 'time command' and other functions
set -o pipefail # trace ERR through pipes
installing_data-archive # calling function
Loading