[TUTORIAL]⁠ Automated Database Backups to Cloud Storage (Rclone)

[TUTORIAL]⁠ Automated Database Backups to Cloud Storage (Rclone)

Welcome to Criminalz!

Join our global tech community to discuss cybersecurity, artificial intelligence, and code development. Register with us to connect, share insights, and private message with other developers and researchers.

SignUp Now!

JackaL

友一人
Joined
Sep 3, 2026
Messages
341
Reaction score
61
[TUTORIAL] Automated Database Backups to Cloud Storage (Rclone)

If your server hard drive crashes, local backups stored on the same machine are useless. Here is how to automate daily encrypted backups of your XenForo database directly to Google Drive, AWS S3, or Backblaze B2 using Rclone.



The Automated Backup Script:
Create a script named backup.sh to dump the database, compress it, and push it to your cloud remote.

Bash:
#!/bin/bash
TIMESTAMP=$(date +"%Y%m%d_%H%M")
BACKUP_DIR="/root/backups"
DB_NAME="your_forum_db"
DB_USER="root"
DB_PASS="your_password"

# Create backup
mkdir -p $BACKUP_DIR
mysqldump -u$DB_USER -p$DB_PASS $DB_NAME | gzip > "$BACKUP_DIR/db_$TIMESTAMP.sql.gz"

# Upload to Cloud via Rclone (remote name: 'myremote', folder: 'forum_backups')
rclone copy "$BACKUP_DIR/db_$TIMESTAMP.sql.gz" myremote:forum_backups

# Delete local backups older than 7 days
find $BACKUP_DIR -type f -mtime +7 -exec rm {} \;
 
Back
Top