Skip to content
Draft
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
20 changes: 18 additions & 2 deletions civo-github/registry/environments/development/postgres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: dev-postgres
namespace: argocd
finalizers:
- resources-finalizer.argocd.argoproj.io
- resources-finalizer.argocd.argoproj.io
annotations:
argocd.argoproj.io/sync-wave: '45'
spec:
Expand Down Expand Up @@ -114,6 +114,7 @@ data:
fi
echo "Created database: $db"
grant_read_access "$db"
restore "$db"
done
}

Expand All @@ -130,7 +131,22 @@ data:
echo "Granted read-only access to database: $DATABASE"
}

# restore existing schema
# --no-acl: prevent restoration of access privileges (grant/revoke commands)
# -v: verbose mode output
function restore() {
local DATABASE=$1
local DUMPFILE="$BACKUP_DIRECTORY/$2.tar"

if [ -f "$DUMPFILE"]
then
echo "Restoring $DATABASE from dumpfile $DUMPFILE"
pg_restore -d $DATABASE --no-acl -v $DUMPFILE
echo "Finished restoring $DATABASE from dumpfile $DUMPFILE"
fi
}

echo "Executing custom initdb ..."
create_users
create_read_role_and_user
create_databases_with_and_set_grant_privileges
create_databases_with_and_set_grant_privileges
20 changes: 18 additions & 2 deletions civo-github/registry/environments/production/postgres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: prd-postgres
namespace: argocd
finalizers:
- resources-finalizer.argocd.argoproj.io
- resources-finalizer.argocd.argoproj.io
annotations:
argocd.argoproj.io/sync-wave: '45'
spec:
Expand Down Expand Up @@ -114,6 +114,7 @@ data:
fi
echo "Created database: $db"
grant_read_access "$db"
restore "$db"
done
}

Expand All @@ -130,7 +131,22 @@ data:
echo "Granted read-only access to database: $DATABASE"
}

# restore existing schema
# --no-acl: prevent restoration of access privileges (grant/revoke commands)
# -v: verbose mode output
function restore() {
local DATABASE=$1
local DUMPFILE="$BACKUP_DIRECTORY/$2.tar"

if [ -f "$DUMPFILE"]
then
echo "Restoring $DATABASE from dumpfile $DUMPFILE"
pg_restore -d $DATABASE --no-acl -v $DUMPFILE
echo "Finished restoring $DATABASE from dumpfile $DUMPFILE"
fi
}

echo "Executing custom initdb ..."
create_users
create_read_role_and_user
create_databases_with_and_set_grant_privileges
create_databases_with_and_set_grant_privileges