Menu Option 21: Data Management

Comprehensive backup, migration, and transfer system for Centmin Mod servers.

Table of Contents

Overview

Menu option 21 in centmin.sh provides a comprehensive data management system for backup, migration, and transfer operations. The underlying scripts are located at /usr/local/src/centminmod/datamanagement/.

Data Management Submenu

Access via centmin.sh → Option 21. Provides 14 submenu options covering SSH keys, S3 profiles, backups, migrations, and transfers.

Menu Option 21
-------------------------------------------------------- Centmin Mod Data Management -------------------------------------------------------- 1). Manage SSH Keys 2). Manage AWS CLI S3 Profile Credentials 3). Migrate Centmin Mod Data To New Centmin Mod Server 4). Backup Nginx Vhosts Data + MariaBackup MySQL Backups 5). Backup Nginx Vhosts Data Only 6). Backup MariaDB MySQL With MariaBackup Only 7). Backup MariaDB MySQL With mysqldump Only 8). Transfer Directory Data To Remote Server Via SSH 9). Transfer Directory Data To S3 Compatible Storage 10). Transfer Files To S3 Compatible Storage 11). Download S3 Compatible Stored Data To Server 12). S3 To S3 Compatible Storage Transfers 13). List S3 Storage Buckets 14). Back to Main menu --------------------------------------------------------

At-a-Glance Quick Reference

Option Name Purpose
1Manage SSH KeysCreate, register, rotate, delete, export, backup SSH keys
2Manage AWS CLI S3 ProfilesCreate, edit, delete, export S3 storage profiles
3Migrate to New ServerComplete server migration with backup + transfer
4Vhosts + MariaBackupFull backup with binary database (physical copy)
5Vhosts OnlyWebsite files backup (no database)
6MariaBackup OnlyBinary database backup (same-version restore)
7mysqldump OnlySQL dump backup (cross-version compatible)
8SSH TransferHigh-speed zstd-compressed tunnel via nc/socat
9–12S3 OperationsUpload, download, sync, and cross-S3 transfers
13List S3 BucketsView S3 buckets for configured profiles

Quick Start Guide

Before using menu option 21, verify these prerequisites:

Requirement Verification Expected
CSF Firewall whitelistcsf -a REMOTE_IPIP added to allow list
SSH key authenticationssh -i /root/.ssh/my1.key root@REMOTE_IPLogin without password
AWS CLI (for S3)aws --versionVersion number displayed
Sufficient disk spacedf -h /homeAt least 2x backup size
MariaDB runningsystemctl status mariadbActive (running)

Quick Command Reference

Task Command
Full backup (Vhosts + MariaBackup)backups.sh backup-all-mariabackup comp
Vhosts only backupbackups.sh backup-files comp
MariaBackup onlybackups.sh backup-mariabackup comp
mysqldump onlybackups.sh backup-all comp
Transfer via SSHtunnel-transfers.sh -p 22 -u root -h REMOTE_IP -m nc -s /path -r /dest -k /root/.ssh/my1.key
Upload to S3aws s3 sync --profile PROFILE --endpoint-url ENDPOINT /path s3://BUCKET/
Restore MariaDBmariabackup-restore.sh copy-back /path/to/mariadb_tmp/

Backup Type Comparison

Choose the right backup method for your situation:

Feature MariaBackup (Option 4/6) mysqldump (Option 7)
Backup SpeedFast (physical copy)Slower (logical dump)
Restore SpeedFastSlower
Cross-VersionNo (same major version only)Yes
Users/PermissionsYes (full MySQL system)Per-database only
File SizeLarger (full datadir)Smaller (SQL text)
Best ForSame-version migrationsVersion upgrades, selective restore

Decision Guide

Migrating to a new server with the same MariaDB major version? Use MariaBackup (Option 3/4). Different versions (e.g., 10.3 → 10.6)? Use mysqldump (Option 7).

SSH Key Management (Submenu 1)

The SSH key manager (keygen.sh) provides full lifecycle management for SSH keys used in remote server operations. SSH key authentication is required for data transfers and migrations.

Available Operations

Option Description
1. List Registered KeysShows all registered SSH keys on the system
2. Register Existing KeyRegister an existing SSH key (provide private and public key paths)
3. Create New KeyGenerate a new key (rsa, ecdsa, or ed25519) and install on remote host
4. Use Existing KeyConfigure an existing key for a remote host connection
5. Rotate KeyReplace the current key with a newly generated one
6. Delete KeyRemove an SSH key for a specified remote host
7. Export KeyExport a key to a specified file path
8. Backup All KeysCreate a backup of all SSH keys to a directory
9. Enable Root Login (Cloud VPS)Enable root SSH on OVH/Hetzner/cloud VPS via sshd_config.d drop-in

Creating a New SSH Key

When creating a new key (Option 3), you will be prompted for:

Prompt Description Default
Key typersa, ecdsa, or ed25519ed25519
Remote IP addressIP of the remote host
Remote SSH portSSH port number22
Remote SSH usernameUsername for remote connectionroot
Key commentUnique identifier for the key

Cloud VPS Support

For OVH, Hetzner, or other cloud VPS providers that disable root SSH login by default, Option 9 enables root login via the sshd_config.d drop-in approach. Supported sudo usernames: almalinux, rocky, opc, cloud-user.

Command Line Usage

Terminal
# Generate new SSH key for remote host keygen.sh gen ed25519 192.168.1.10 22 root mykey-comment # Rotate existing SSH key keygen.sh rotatekeys ed25519 192.168.1.10 22 root mykey-comment keyname

AWS CLI S3 Profiles (Submenu 2)

Manage AWS CLI S3 profile credentials for S3-compatible storage providers. Required for S3 upload/download/sync operations (Submenus 9–13).

Creating a New S3 Profile

When creating a new profile (Option 3), you provide:

Prompt Description
S3 storage providerAWS, Cloudflare R2, Backblaze, DigitalOcean, etc.
Profile nameUnique name (e.g., r2, b2, do)
Endpoint URLS3-compatible endpoint for the provider
Access KeyYour access key ID
Secret KeyYour secret access key
Default RegionRegion code (e.g., us-east-1, auto)

S3 Provider Endpoint Reference

Provider Profile Endpoint URL
Amazon S3awshttps://s3.REGION.amazonaws.com
Cloudflare R2r2https://ACCOUNT_ID.r2.cloudflarestorage.com
Backblaze B2b2https://s3.REGION.backblazeb2.com
DigitalOcean Spacesdohttps://REGION.digitaloceanspaces.com
Linode Object Storagelinodehttps://REGION.linodeobjects.com
Vultr Object Storagevultrhttps://REGION.vultrobjects.com
Wasabiwasabihttps://s3.REGION.wasabisys.com
UpCloudupcloudhttps://REGION.upcloudobjects.com

Command Line Usage

Terminal
# Install AWS CLI and create a profile awscli-get.sh install PROFILE ACCESS_KEY SECRET_KEY REGION OUTPUT # Update AWS CLI awscli-get.sh update

Server Migration (Submenu 3)

Complete server migration with automatic backup and transfer. This combines backup (Option 4 or 7) with SSH tunnel transfer to move all data to a new Centmin Mod server.

Important

Migrations are not finalized until you change the domain's DNS records. You can perform test migrations on test servers until you are comfortable with the final move.

Pre-Migration Checklist

  • Both servers have Centmin Mod installed
  • CSF Firewall allows traffic between servers (csf -a REMOTE_IP on both)
  • SSH key authentication is configured (Submenu 1)
  • Sufficient disk space on both servers
  • MariaDB versions documented on both servers
  • Test migration planned (do not change DNS until verified)

Migration Workflow

  1. Select backup method: MariaBackup (same DB version) or mysqldump (different versions)
  2. Optional compression: tar + zstd for faster transfers
  3. Backup created at /home/databackup/TIMESTAMP/
  4. Transfer via SSH: Configure tunnel-transfers.sh parameters
  5. Restore on destination: Extract, compare, restore files and database
  6. Verify: Test nginx config (nginx -t), check sites
  7. Update DNS when ready to go live

Command Line Usage

Terminal
# Step 1: Create full backup with compression backups.sh backup-all-mariabackup comp 2>&1 | tee backup-all.log # Step 2: Get backup directory from log transfer_backup_dir=$(grep 'Backup Log saved: ' backup-all.log \ | awk '{print $10}' | xargs dirname) # Step 3: Transfer to remote server via SSH tunnel-transfers.sh \ -p 22 \ -u root \ -h 123.123.123.123 \ -m nc \ -b 262144 \ -l 12345 \ -s ${transfer_backup_dir} \ -r /home/remotebackup \ -k /root/.ssh/my1.key

MariaBackup Backups (Submenu 4 & 6)

MariaBackup creates physical/binary backups of MariaDB databases. This is the fastest method for backup and restore, but requires the same MariaDB major version on source and destination.

Submenu 4: Vhosts + MariaBackup (Full Backup)

Creates a complete backup of website files AND database. Includes:

  • Nginx configuration files and vhost directories
  • Centmin Mod configuration (/etc/centminmod/)
  • MariaDB physical backup (all databases, users, permissions)
  • Optional tar + zstd compression
  • MariaBackup restore script included in backup

Submenu 6: MariaBackup Only

Database-only backup without website files. Useful for daily database backups.

Command Line Usage

Terminal
# Full backup: Vhosts + MariaBackup (with compression) backups.sh backup-all-mariabackup comp # Full backup: Vhosts + MariaBackup (no compression) backups.sh backup-all-mariabackup # MariaBackup only (with compression) backups.sh backup-mariabackup comp # MariaBackup only (no compression) backups.sh backup-mariabackup # Vhosts only (with compression) backups.sh backup-files comp

Custom Directories

You can extend the default backup directories by creating /etc/centminmod/backups.ini. Add custom paths to DIRECTORIES_TO_BACKUP and DIRECTORIES_TO_BACKUP_NOCOMPRESS arrays.

mysqldump Backups (Submenu 7)

Logical/SQL dump backup using mysqldump. Slower than MariaBackup but cross-version compatible, making it the right choice for MariaDB version upgrades.

Key Features

  • Uses the faster --tab delimited backup option
  • Creates separate .sql schema structure files and .txt data files per table
  • Schema files are uncompressed; data files can be zstd compressed
  • Generates a restore.sh script in the backup directory
  • If database name already exists on restore, creates _restorecopy_datetimestamp to prevent overwrites

Command Line Usage

Terminal
# mysqldump backup (with compression) backups.sh backup-all comp # mysqldump backup (no compression) backups.sh backup-all # mysqldump only - no vhosts backups.sh backup-mysql

SSH Tunnel Transfers (Submenu 8)

High-speed data transfer via SSH using netcat (nc) or socat tunnels with zstd compression. Transfers at speeds near network and disk line rates.

tunnel-transfers.sh Parameters

Flag Description Default
-pSSH port22
-uSSH usernameroot
-hRemote hostname/IP
-mTunnel method (nc or socat)nc
-bBuffer size (bytes)131072
-lListen port12345
-sSource directory
-rRemote destination
-kSSH private key path

Example

Terminal
# Transfer backup directory to remote server tunnel-transfers.sh \ -p 22 \ -u root \ -h 123.123.123.123 \ -m nc \ -b 262144 \ -l 12345 \ -s /home/databackup/070523-072252 \ -r /home/remotebackup \ -k /root/.ssh/my1.key

Performance Benchmarks

Method Distance Expected Speed
SSH tunnel (nc)Same datacenter300–500 MB/s
SSH tunnel (nc)Cross-region50–150 MB/s
SSH tunnel (socat)AnySimilar to nc, better for unstable connections
S3 syncCloud provider50–200 MB/s

S3 Uploads & Downloads (Submenus 9–13)

Transfer data to and from S3-compatible storage providers using AWS CLI. Requires a configured S3 profile (Submenu 2).

S3 Operations

Submenu Operation AWS CLI Command
9Sync directory to S3aws s3 sync
10Upload files to S3aws s3 cp
11Download from S3aws s3 cp (from S3)
12S3 to S3 transferaws s3 cp (S3 to S3)
13List S3 bucketsaws s3 ls

S3 Command Examples

Terminal
# Sync directory to Cloudflare R2 aws s3 sync --profile r2 \ --endpoint-url https://ACCOUNT_ID.r2.cloudflarestorage.com \ /home/databackup/070523-072252 s3://BUCKET/ # Upload file to S3 aws s3 cp --profile PROFILE \ --endpoint-url ENDPOINT \ /path/to/file.tar.zst s3://BUCKET/ # Download from S3 aws s3 cp --profile PROFILE \ --endpoint-url ENDPOINT \ s3://BUCKET/file.tar.zst /home/localdirectory/ # List buckets aws s3 ls --profile PROFILE --endpoint-url ENDPOINT

Restore Procedures

After transferring backup data to the destination server, follow these steps to restore.

Step 1: Extract the Backup

Terminal
# Create restore directory and extract (tar 1.31+ with zstd) mkdir -p /home/restoredata tar -I zstd -xf /home/remotebackup/centminmod_backup.tar.zst \ -C /home/restoredata

Step 2: Understand Backup Structure

Backup Path Original Location Contents
/home/restoredata/etc/centminmod/etc/centminmodCentmin Mod configs
/home/restoredata/etc/pure-ftpd/etc/pure-ftpdVirtual FTP user database
.../TIMESTAMP/domains_tmp/home/nginx/domainsNginx vhost directories
.../TIMESTAMP/mariadb_tmp/var/lib/mysqlMariaDB data + restore script
/home/restoredata/root/tools/root/toolsCentmin Mod tools
/home/restoredata/usr/local/nginx/usr/local/nginxNginx installation

Step 3: Compare Before Restoring

Terminal
# Compare backup vs destination before restoring diff -ur /etc/centminmod /home/restoredata/etc/centminmod/ diff -ur /usr/local/nginx /home/restoredata/usr/local/nginx/ diff -ur /root/tools /home/restoredata/root/tools/

Step 4: Backup New Server Files First

Always Backup Before Overwriting

Before restoring, backup the new server's existing configuration files so you can revert if needed.

Terminal
# Backup new server configs before overwriting \cp -af /usr/local/nginx /usr/local/nginx_original \cp -af /etc/centminmod/custom_config.inc \ /etc/centminmod/custom_config.inc.original \cp -af /etc/my.cnf /etc/my.cnf.original \cp -af /root/.my.cnf /root/.my.cnf.original

Step 5: Restore Files

Terminal
# Restore configuration files \cp -af /home/restoredata/etc/centminmod/* /etc/centminmod/ \cp -af /home/restoredata/usr/local/nginx/* /usr/local/nginx/ \cp -af /home/restoredata/root/tools/* /root/tools/ # Restore Nginx vhost data (replace TIMESTAMP) \cp -af /home/restoredata/home/databackup/TIMESTAMP/domains_tmp/* \ /home/nginx/domains/ # Restore cronjobs crontab /home/remotebackup/cronjobs_tmp/root_cronjobs

Step 6: Restore MariaDB Database

The mariabackup-restore.sh script is included in each MariaBackup backup:

Option Behavior
copy-backCopies backup files to /var/lib/mysql, preserves backup
move-backMoves backup files to /var/lib/mysql, removes backup (saves disk space)
Terminal
# Restore MariaDB (replace TIMESTAMP with actual value) mariabackup-restore.sh copy-back \ /home/restoredata/home/databackup/TIMESTAMP/mariadb_tmp/ # Restore MySQL credentials \cp -af /home/restoredata/root/.my.cnf /root/.my.cnf # Verify Nginx config nginx -t # Reload Nginx ngxreload

Version Mismatch

The mariabackup-restore.sh script validates MariaDB versions and aborts if they do not match. Use mysqldump for cross-version migrations.

Recommended Backup Schedule

Backup Type Frequency Command
Full (Vhosts + MariaBackup)Weeklybackups.sh backup-all-mariabackup comp
MariaBackup OnlyDailybackups.sh backup-mariabackup comp
Vhosts OnlyDailybackups.sh backup-files comp
mysqldumpBefore upgradesbackups.sh backup-all comp
S3 Offsite SyncDailyaws s3 sync ...

3-2-1 Backup Rule

Keep 3 copies of your data on 2 different storage media with 1 offsite copy (S3-compatible storage). Use zstd compression for 60–80% size reduction.

Need help with backups or migrations?

Join the community forums for data management help and migration tips.