From 104366bc64b22583c867ca22a2ee4688c19098e6 Mon Sep 17 00:00:00 2001 From: "push-app-to-main[bot]" <203845782+push-app-to-main[bot]@users.noreply.github.com> Date: Tue, 17 Feb 2026 10:40:58 +0100 Subject: [PATCH] Databasus (#12018) * Add databasus (ct) * Update databasus.sh * Update databasus-install.sh * Fix backup and restore paths for Databasus config --------- Co-authored-by: push-app-to-main[bot] <203845782+push-app-to-main[bot]@users.noreply.github.com> Co-authored-by: CanbiZ (MickLesk) <47820557+MickLesk@users.noreply.github.com> Co-authored-by: Tobias <96661824+CrazyWolf13@users.noreply.github.com> --- ct/databasus.sh | 78 +++++++++++++ frontend/public/json/databasus.json | 44 +++++++ install/databasus-install.sh | 171 ++++++++++++++++++++++++++++ 3 files changed, 293 insertions(+) create mode 100644 ct/databasus.sh create mode 100644 frontend/public/json/databasus.json create mode 100644 install/databasus-install.sh diff --git a/ct/databasus.sh b/ct/databasus.sh new file mode 100644 index 000000000..a189ebdba --- /dev/null +++ b/ct/databasus.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +# Copyright (c) 2021-2026 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/databasus/databasus + +APP="Databasus" +var_tags="${var_tags:-backup;postgresql;database}" +var_cpu="${var_cpu:-2}" +var_ram="${var_ram:-2048}" +var_disk="${var_disk:-8}" +var_os="${var_os:-debian}" +var_version="${var_version:-13}" +var_unprivileged="${var_unprivileged:-1}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + + if [[ ! -f /opt/databasus/databasus ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + if check_for_gh_release "databasus" "databasus/databasus"; then + msg_info "Stopping Databasus" + $STD systemctl stop databasus + msg_ok "Stopped Databasus" + + msg_info "Backing up Configuration" + cp /opt/databasus/.env /opt/databasus.env.bak + msg_ok "Backed up Configuration" + + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "databasus" "databasus/databasus" "tarball" "latest" "/opt/databasus" + + msg_info "Updating Databasus" + cd /opt/databasus/frontend + $STD npm ci + $STD npm run build + cd /opt/databasus/backend + $STD go mod download + $STD /root/go/bin/swag init -g cmd/main.go -o swagger + $STD env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o databasus ./cmd/main.go + mv /opt/databasus/backend/databasus /opt/databasus/databasus + cp -r /opt/databasus/frontend/dist/* /opt/databasus/ui/build/ + cp -r /opt/databasus/backend/migrations /opt/databasus/ + chown -R postgres:postgres /opt/databasus + msg_ok "Updated Databasus" + + msg_info "Restoring Configuration" + cp /opt/databasus.env.bak /opt/databasus/.env + rm -f /opt/databasus.env.bak + chown postgres:postgres /opt/databasus/.env + msg_ok "Restored Configuration" + + msg_info "Starting Databasus" + $STD systemctl start databasus + msg_ok "Started Databasus" + msg_ok "Updated successfully!" + fi + exit +} + +start +build_container +description + +msg_ok "Completed successfully!\n" +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" +echo -e "${INFO}${YW} Access it using the following URL:${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}${CL}" diff --git a/frontend/public/json/databasus.json b/frontend/public/json/databasus.json new file mode 100644 index 000000000..766d88925 --- /dev/null +++ b/frontend/public/json/databasus.json @@ -0,0 +1,44 @@ +{ + "name": "Databasus", + "slug": "databasus", + "categories": [ + 7 + ], + "date_created": "2025-01-14", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 80, + "documentation": "https://github.com/databasus/databasus", + "website": "https://github.com/databasus/databasus", + "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/databasus.webp", + "config_path": "/opt/databasus/.env", + "description": "Free, open source and self-hosted solution for automated PostgreSQL backups. With multiple storage options, notifications, scheduling, and a beautiful web interface for managing database backups across multiple PostgreSQL instances.", + "install_methods": [ + { + "type": "default", + "script": "ct/databasus.sh", + "resources": { + "cpu": 2, + "ram": 2048, + "hdd": 8, + "os": "Debian", + "version": "13" + } + } + ], + "default_credentials": { + "username": "admin@localhost", + "password": "See /root/databasus.creds" + }, + "notes": [ + { + "text": "Supports PostgreSQL versions 12-18 with cloud and self-hosted instances", + "type": "info" + }, + { + "text": "Features: Scheduled backups, multiple storage providers, notifications, encryption", + "type": "info" + } + ] +} diff --git a/install/databasus-install.sh b/install/databasus-install.sh new file mode 100644 index 000000000..fa17a4d58 --- /dev/null +++ b/install/databasus-install.sh @@ -0,0 +1,171 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2026 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/databasus/databasus + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt install -y \ + nginx \ + valkey +msg_ok "Installed Dependencies" + +PG_VERSION="17" setup_postgresql +setup_go +NODE_VERSION="24" setup_nodejs + +fetch_and_deploy_gh_release "databasus" "databasus/databasus" "tarball" "latest" "/opt/databasus" + +msg_info "Building Databasus (Patience)" +cd /opt/databasus/frontend +$STD npm ci +$STD npm run build +cd /opt/databasus/backend +$STD go mod tidy +$STD go mod download +$STD go install github.com/swaggo/swag/cmd/swag@latest +$STD /root/go/bin/swag init -g cmd/main.go -o swagger +$STD env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o databasus ./cmd/main.go +mv /opt/databasus/backend/databasus /opt/databasus/databasus +mkdir -p /databasus-data/{pgdata,temp,backups,data,logs} +mkdir -p /opt/databasus/ui/build +mkdir -p /opt/databasus/migrations +cp -r /opt/databasus/frontend/dist/* /opt/databasus/ui/build/ +cp -r /opt/databasus/backend/migrations/* /opt/databasus/migrations/ +chown -R postgres:postgres /databasus-data +msg_ok "Built Databasus" + +msg_info "Configuring Databasus" +JWT_SECRET=$(openssl rand -hex 32) +ENCRYPTION_KEY=$(openssl rand -hex 32) +# Create PostgreSQL version symlinks for compatibility +for v in 12 13 14 15 16 18; do + ln -sf /usr/lib/postgresql/17 /usr/lib/postgresql/$v +done +# Install goose for migrations +$STD go install github.com/pressly/goose/v3/cmd/goose@latest +ln -sf /root/go/bin/goose /usr/local/bin/goose +cat </opt/databasus/.env +# Environment +ENV_MODE=production + +# Server +SERVER_PORT=4005 +SERVER_HOST=0.0.0.0 + +# Database +DATABASE_DSN=host=localhost user=postgres password=postgres dbname=databasus port=5432 sslmode=disable +DATABASE_URL=postgres://postgres:postgres@localhost:5432/databasus?sslmode=disable + +# Migrations +GOOSE_DRIVER=postgres +GOOSE_DBSTRING=postgres://postgres:postgres@localhost:5432/databasus?sslmode=disable +GOOSE_MIGRATION_DIR=/opt/databasus/migrations + +# Valkey (Redis-compatible cache) +VALKEY_HOST=localhost +VALKEY_PORT=6379 + +# Security +JWT_SECRET=${JWT_SECRET} +ENCRYPTION_KEY=${ENCRYPTION_KEY} + +# Paths +DATA_DIR=/databasus-data/data +BACKUP_DIR=/databasus-data/backups +LOG_DIR=/databasus-data/logs +EOF +chown postgres:postgres /opt/databasus/.env +chmod 600 /opt/databasus/.env +msg_ok "Configured Databasus" + +msg_info "Configuring Valkey" +cat </etc/valkey/valkey.conf +port 6379 +bind 127.0.0.1 +protected-mode yes +save "" +maxmemory 256mb +maxmemory-policy allkeys-lru +EOF +systemctl enable -q --now valkey-server +systemctl restart valkey-server +msg_ok "Configured Valkey" + +msg_info "Creating Database" +# Configure PostgreSQL to allow local password auth for databasus +PG_HBA="/etc/postgresql/17/main/pg_hba.conf" +if ! grep -q "databasus" "$PG_HBA"; then + sed -i '/^local\s*all\s*all/i local databasus postgres trust' "$PG_HBA" + sed -i '/^host\s*all\s*all\s*127/i host databasus postgres 127.0.0.1/32 trust' "$PG_HBA" + systemctl reload postgresql +fi +$STD sudo -u postgres psql -c "CREATE DATABASE databasus;" 2>/dev/null || true +$STD sudo -u postgres psql -c "ALTER USER postgres WITH SUPERUSER CREATEROLE CREATEDB;" 2>/dev/null || true +msg_ok "Created Database" + +msg_info "Creating Databasus Service" +cat </etc/systemd/system/databasus.service +[Unit] +Description=Databasus - Database Backup Management +After=network.target postgresql.service valkey.service +Requires=postgresql.service valkey.service + +[Service] +Type=simple +WorkingDirectory=/opt/databasus +EnvironmentFile=/opt/databasus/.env +ExecStart=/opt/databasus/databasus +Restart=always +RestartSec=5 +StandardOutput=journal +StandardError=journal + +[Install] +WantedBy=multi-user.target +EOF +$STD systemctl daemon-reload +$STD systemctl enable -q --now databasus +msg_ok "Created Databasus Service" + +msg_info "Configuring Nginx" +cat </etc/nginx/sites-available/databasus +server { + listen 80; + server_name _; + + location / { + proxy_pass http://127.0.0.1:4005; + proxy_http_version 1.1; + proxy_set_header Upgrade \$http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host \$host; + proxy_set_header X-Real-IP \$remote_addr; + proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto \$scheme; + proxy_cache_bypass \$http_upgrade; + proxy_buffering off; + proxy_read_timeout 86400s; + proxy_send_timeout 86400s; + } +} +EOF +ln -sf /etc/nginx/sites-available/databasus /etc/nginx/sites-enabled/databasus +rm -f /etc/nginx/sites-enabled/default +$STD nginx -t +$STD systemctl enable -q --now nginx +$STD systemctl reload nginx +msg_ok "Configured Nginx" + +motd_ssh +customize +cleanup_lxc