Guide Contents
Why do we need backups in the first place?
A quick manual backup
Export the entire database into a single file
mysqldump -u workup_user -p workup > ~/workup_backup_$(date +%F).sql
mysqldump reads every table in the workup database and converts it into text SQL commands inside a single file (the same idea as the db.sql file we imported during installation, but this time it holds your real data). $(date +%F) automatically appends today's date to the file name (like workup_backup_2026-07-17.sql) so you don't mix up different backups.
Make sure the file was actually created and its size makes sense (not zero):
ls -lh ~/workup_backup_*.sql
Automatic daily backup via Cron
Create a simple backup script
sudo mkdir -p /var/backups/workup sudo nano /usr/local/bin/workup-backup.sh
Paste this exact content:
#!/bin/bash # Today's date, used for naming the files DATE=$(date +%F) # Database backup mysqldump -u workup_user -p'put_password_here' workup > /var/backups/workup/db_$DATE.sql # Backup of the files folder (images and attachments) as a single compressed archive tar -czf /var/backups/workup/files_$DATE.tar.gz -C /var/www/html/WorkUp files # Delete any backup older than 14 days so the disk doesn't fill up find /var/backups/workup -type f -mtime +14 -delete
This script does three things in order: (1) backs up the database, (2) compresses the entire files folder into one small file, (3) automatically deletes backups older than two weeks so disk space doesn't fill up over time.
Make the script executable:
sudo chmod +x /usr/local/bin/workup-backup.sh
put_password_here with the real password for workup_user, and make sure this file is readable only by the administrator: sudo chmod 700 /usr/local/bin/workup-backup.sh — because it contains the database password as plain text.
Schedule it daily via crontab
sudo crontab -e
Add this line at the end of the file (choose nano if it asks you for an editor):
0 3 * * * /usr/local/bin/workup-backup.sh
This literally means: "run this script every day at 3:00 AM". The five numbers are, in order: minute, hour, day of month, month, day of week — and the asterisk * means "any value, no condition".
Backing up the files folder (images and attachments)
files/ folder on disk, not inside the database. That's why the script above also backs it up (tar -czf) alongside the database backup — together, the two form a genuine "complete backup".
Storing a copy off the server
Periodically copy backups to a completely separate location
The simplest way: copy them from your personal computer (not from the server) with a single command, weekly:
scp root@server_IP_address:/var/backups/workup/*.sql ~/workup-backups-local/ scp root@server_IP_address:/var/backups/workup/*.tar.gz ~/workup-backups-local/
Better alternatives for the long term: upload them automatically to a cloud storage service (Google Drive, Dropbox, or Amazon S3) using a tool like rclone. The core idea is always the same: don't trust just one location.
How to restore a backup when needed
Restoring the database
mysql -u workup_user -p workup < /var/backups/workup/db_2026-07-17.sql
Restoring the files folder
# Extract to a temporary location first to verify its contents tar -xzf /var/backups/workup/files_2026-07-17.tar.gz -C /tmp/restore-check # After verifying, copy it to the actual location (replaces the current folder) sudo rm -rf /var/www/html/WorkUp/files sudo tar -xzf /var/backups/workup/files_2026-07-17.tar.gz -C /var/www/html/WorkUp sudo chown -R www-data:www-data /var/www/html/WorkUp/files sudo chmod -R 775 /var/www/html/WorkUp/files
Don't forget to reset permissions after restoring (the same permissions as the installation step) — files restored from a backup may carry different permissions than what the server needs.