Skip to Content
SnippetsOperations
Open in ChatGPTOpen in Claude

Operations Snippets

Common operational configurations. Replace every path, hostname, user, and certificate placeholder before deployment. Run services with a dedicated unprivileged account, validate configuration syntax before reloads, and keep a tested rollback path for each operational change. Store secrets outside committed service and proxy configuration files.

systemd Service

[Unit] Description=FiveM Server After=network.target [Service] Type=simple User=fivem WorkingDirectory=/opt/fivem ExecStart=/opt/fivem/run.sh +exec server.cfg Restart=always RestartSec=5 [Install] WantedBy=multi-user.target

Nginx Reverse Proxy

⚠️

This proxies the txAdmin admin panel. Never publish it to everyone: restrict it to your admin IPs (as below) or serve it only on a VPN, keep port 40120 itself firewalled, and read txAdmin security first. An SSH tunnel needs no proxy at all.

server { listen 443 ssl; server_name your-domain.com; ssl_certificate /path/to/cert.pem; ssl_certificate_key /path/to/key.pem; # Only your admin IPs may reach the panel allow <ADMIN_IP>; deny all; location / { proxy_pass http://127.0.0.1:40120; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; # txAdmin uses socket.io (WebSocket) for the live console and dashboard proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } }

Backup Script

Use a dedicated read-only database user, not root, and keep its password in ~/.my.cnf (mode 600) of the account that runs the cron job, so the script never prompts and the password never appears in the process list:

[client] user=fivem_backup password=CHANGE_ME
#!/bin/bash set -euo pipefail umask 077 BACKUP_DIR="/opt/fivem/backups" SERVER_DIR="/opt/fivem/server-data" DB_NAME="fivem" DATE=$(date +%Y%m%d_%H%M%S) mkdir -p "$BACKUP_DIR/$DATE" # Backup database (credentials come from ~/.my.cnf) mariadb-dump --single-transaction --quick "$DB_NAME" \ | gzip > "$BACKUP_DIR/$DATE/db.sql.gz" # Backup resources and server.cfg tar -czf "$BACKUP_DIR/$DATE/resources.tar.gz" \ -C "$SERVER_DIR" resources server.cfg

See txAdmin backups and Server backups for restore testing and off-server copies.