Regular backups and maintenance keep your ChatNet installation running smoothly and protect against data loss. This section explains what files and data to backup (database, media, configuration), how to perform manual and automated backups, setting up cron jobs for scheduled tasks, database optimization techniques, and general maintenance tips like clearing old files and rotating logs. Establish a backup routine before you need it.
Critical files and data that must be included in your backup routine.
| Item | Location | Priority |
|---|---|---|
| Database | MySQL dump | Critical |
| Media Files | /media/ folder | Critical |
| Configuration | /config/settings.php | High |
| Plugins | /plugins/ folder | Medium |
| Customizations | Custom CSS/templates | Medium |
Export your MySQL database to preserve all user data, messages, and settings.
mysqldump -u username -p database_name > backup_$(date +%Y%m%d).sqlPreserve user-uploaded files including images, attachments, and audio clips.
# Compress and backup media folder tar -czvf media_backup_$(date +%Y%m%d).tar.gz /path/to/chatnet/media/Or use FTP to download the /media/ folder.
Set up a cron job for automatic backups:
# Daily database backup at 2 AM 0 2 * * * mysqldump -u user -ppassword dbname > /backups/db_$(date +\%Y\%m\%d).sql # Weekly media backup 0 3 * * 0 tar -czvf /backups/media_$(date +\%Y\%m\%d).tar.gz /path/to/media/ChatNet may require cron jobs for background tasks:
# Run ChatNet cron every minute * * * * * php /path/to/chatnet/cron.php >> /var/log/chatnet-cron.log 2>&1Regular maintenance tasks to keep your ChatNet installation running smoothly.
Run periodically to optimize tables:
OPTIMIZE TABLE cn_group_chats, cn_private_chats, cn_notifications;Or via phpMyAdmin: Select tables > Optimize.
Remove old temporary files:
# Delete temp files older than 7 days find /path/to/chatnet/media/temp -type f -mtime +7 -deletePrevent logs from growing too large:
# Clear old logs find /path/to/logs -name "*.log" -mtime +30 -delete