Ir al contenido

DOC-05: Operations and Maintenance (Day 2 Operations)

Recurring maintenance manual, backup automation without credential exposure, and Disaster Recovery plans for Redmine infrastructure.

0views

The resilience of a corporate environment resides entirely in its disaster recovery capability. To ensure a robust backup strategy, we implement the principle of data segregation and the elimination of plain-text passwords on system terminals.

[!CAUTION] Credential Exposure Risk: Never pass the MySQL password interactively in the terminal (e.g., -p"mi_contraseña"). Doing so will record the password in plain text in the bash command history (~/.bash_history) and in the system process table, visible to any local user via ps aux.

To resolve this security breach, we implement a secure MySQL client configuration file (.my.cnf) inside the container or mounted as a volume.

Step 1: Configure the secure credentials file on the host

Sección titulada «Paso 1: Configurar el archivo de credenciales seguro en el host»

Create a MySQL client options file within your host server's protected configuration directory:

Ventana de terminal
mkdir -p ~/redmine/config/secrets
nano ~/redmine/config/secrets/mysql_backup.cnf

Add the database administration credentials in a structured manner:

[client]
user=redmine
password=contrasena_secreta_portelcore
host=redmine_db

Only the infrastructure automation service account (portel_user) and the Docker daemon should be able to read this file:

Ventana de terminal
chmod 600 ~/redmine/config/secrets/mysql_backup.cnf

Step 3: Mapping and Execution in the Compose file

Sección titulada «Paso 3: Mapeo y Ejecución en el archivo Compose»

Ensure that the mysql_backup.cnf file is mounted to the redmine_db service of the docker-compose.yml file in read-only mode (:ro):

services:
redmine_db:
# ... otras configuraciones
volumes:
- ./config/secrets/mysql_backup.cnf:/etc/mysql/conf.d/mysql_backup.cnf:ro

Once mapped, execute the database dump from your scheduled task script (CRON) without revealing any passwords in the logs or the system history:

Ventana de terminal
# Ejecución segura mediante el uso del archivo de configuración interno
docker exec -i redmine_db mysqldump --defaults-extra-file=/etc/mysql/conf.d/mysql_backup.cnf redmine > ~/redmine/backups/redmine_backup_$(date +%F).sql

Redmine stores portal attachments, premium visual themes, and integrated plugins in host directories. To back them up, we create a high-performance compressed archive:

Ventana de terminal
# Compresión recursiva preservando metadatos y permisos originales de Linux
tar -czpf ~/redmine/backups/redmine_assets_$(date +%F).tar.gz -C ~/redmine files themes plugins config

In the event of total data loss or physical host corruption, follow this step-by-step procedure to restore operations on a new node:

  1. Provisioning: Install the operating system and set up the empty infrastructure following guides DOC-01, DOC-02, and DOC-03.
  2. Temporary Halt: Stop the application container to avoid write inconsistencies while restoring data:
    Ventana de terminal
    cd ~/redmine
    docker compose stop redmine
  3. Database Restoration: Import the SQL dump using the already configured secure connection:
    Ventana de terminal
    docker exec -i redmine_db mysql --defaults-extra-file=/etc/mysql/conf.d/mysql_backup.cnf redmine < ~/redmine/backups/redmine_backup_2026-05-22.sql
  4. File Restoration: Unzip the files and plugins into their respective locations on the host, making sure to overwrite the empty persistent directories:
    Ventana de terminal
    tar -xzpf ~/redmine/backups/redmine_assets_2026-05-22.tar.gz -C ~/redmine
  5. Permission Reconfiguration: Reapply the production isolated user (999) ownership to the file system:
    Ventana de terminal
    sudo chown -R 999:999 ~/redmine/files ~/redmine/themes ~/redmine/plugins ~/redmine/config
  6. Complete Boot: Initialize the application again:
    Ventana de terminal
    docker compose start redmine

To keep the Redmine instance protected against Ruby on Rails framework vulnerabilities and to leverage the latest performance improvements:

  1. Backup: Perform a manual backup of the database and attachments (section 1).
  2. Update the Registry Image: Download the latest official stable version tag:
    Ventana de terminal
    docker compose pull redmine
  3. Stop and Recreation: Stop and lift the stack in the background. Docker will recreate the containers immutably from the new base image:
    Ventana de terminal
    docker compose down
    Ventana de terminal
    docker compose up -d
  4. Database and Plugin Migration: If the version jump introduces changes to the relational database schema or Redmine plugins, directly invoke the compilation Rake task:
    Ventana de terminal
    docker compose run --rm redmine bundle exec rake redmine:plugins:migrate RAILS_ENV=production

Implement this weekly checklist to ensure the system remains healthy and that maintenance policies are rigorously enforced:

  • ✓ Backup Status: Verify that daily SQL dumps are correctly generated in ~/redmine/backups/ and are not zero-sized.
  • ✓ Owner Verification (UID 999): Ensure that no files uploaded by users through the attachments portal have broken the local server's permission hierarchy.
  • ✓ Disk Space Sanitization: Purge orphaned images and volumes from the Docker engine to prevent lack of space on the Proxmox hypervisor's virtual hard drive.
  • ✓ Lab DNS Consistency: Verify the correct internal resolution of domains under the *.portelcore.com extension.