Ana içeriğe geç

Automated XenForo Backups: Offsite Rclone, MySQL & Restore Drills

Automated XenForo Backups: Offsite Rclone, MySQL & Restore Drills

Administrator
Automated XenForo Backups: Offsite Rclone, MySQL & Restore Drills
Relying solely on local web-host snapshots leaves a XenForo community vulnerable to billing lockouts, disk corruption, and accidental administrative deletions. Implementing an automated 3-2-1 backup strategy—combining non-blocking MySQL dumps, incremental attachment syncing via rclone, and periodic staging restore drills—guarantees rapid recovery with minimal data loss.



Creating Consistent MySQL Dumps Without Table Locks
Running a standard database export on a busy forum can lock core InnoDB tables such as xf_post and xf_session_activity, causing timeouts for active members. Use mysqldump with the --single-transaction flag to capture a point-in-time snapshot without interrupting live writes, and pipe the output directly through gzip to conserve disk space:
Kod:
#!/bin/bash BACKUP_DIR="/var/backups/xenforo" DATE=$(date +%F_%H-%M) mkdir -p "$BACKUP_DIR" mysqldump --single-transaction --quick --routines --triggers \ -u xf_db_user -p'YOUR_DB_PASSWORD' xf_database | gzip > "$BACKUP_DIR/xf_db_$DATE.sql.gz" # Retain only the last 7 days of local SQL archives find "$BACKUP_DIR" -name "xf_db_*.sql.gz" -mtime +7 -delete
Store database credentials inside a restricted ~/.my.cnf file (chmod 600) rather than passing passwords inline on production servers so credentials never appear in system process lists.



Syncing Attachments to Offsite Object Storage with Rclone
Archiving tens of gigabytes of data/ and internal_data/ attachments into monolithic tarballs every night wastes CPU cycles and NVMe wear. Instead, configure rclone to transfer compressed daily SQL dumps alongside incremental changes from your attachment and configuration directories to an offsite S3-compatible bucket such as Backblaze B2, Cloudflare R2, or Amazon S3:
Kod:
rclone copy /var/backups/xenforo remote:xf-offsite-backups/db/ rclone copy /var/www/xenforo/src/config.php remote:xf-offsite-backups/config/ rclone sync /var/www/xenforo/data remote:xf-offsite-backups/data --transfers=8 rclone sync /var/www/xenforo/internal_data remote:xf-offsite-backups/internal_data --transfers=8
Schedule both the database dump script and the rclone commands via crontab during off-peak traffic hours, and enable bucket versioning on your offsite provider so accidentally deleted attachments remain recoverable for at least 30 days.



Running Quarterly Disaster Recovery Restore Drills
An untested backup archive offers no guarantee against corrupted SQL encodings or missing file permissions. Every quarter, validate your backup pipeline by restoring your latest archive onto an isolated staging subdomain or local virtual machine:
  1. Extract the XenForo web root files, restore data/ and internal_data/ from your offsite bucket, and import the .sql.gz dump into a clean staging database.
  2. Before opening the staging URL in a browser, append $config['enableMail'] = false; and $config['enableListeners'] = false; to the staging src/config.php file so test sessions never trigger real member emails or outbound webhook calls.
  3. Log into the staging AdminCP, verify recent attachments and user logins, and record the total time required to complete the restore so your recovery procedure is documented before an emergency occurs.
İşin Doğrusu Youtube Kanalı

Konu ile Alakalı Benzer Konular

Zamanlanmış görev