Files
tilbudgivern/_archive/DATABASE_BACKUP_QUICKSTART.md
alexpolo1 eb03213f16 oprydning
2025-11-26 12:36:27 +00:00

2.7 KiB

Database Backup Setup - Quick Start

📋 Files Created

/mnt/HC_Volume_103713257/tilbudgivern/
├── scripts/
│   ├── backup-databases.sh          # Main backup script
│   └── setup-backups.sh             # Automated setup script
├── backups/                          # Backup directory (auto-created)
├── logs/
│   └── backups/
│       └── backup.log               # Backup logs
└── infra/
    └── logrotate-backups.conf       # Logrotate configuration
└── docs/
    └── DATABASE_BACKUP_SETUP.md     # Full documentation

🚀 Quick Start (2 steps)

Step 1: Run Setup Script

sudo bash /mnt/HC_Volume_103713257/tilbudgivern/scripts/setup-backups.sh

This will:

  • Set execute permissions
  • Create backup directories
  • Add crontab entry
  • Optionally install logrotate config

Step 2: Configure Database Credentials

Edit .env:

nano /mnt/HC_Volume_103713257/tilbudgivern/backend/.env

Add:

DB_USER=root
DB_PASSWORD=your_password
DB_HOST=localhost

What You Get

Daily automated backups with:

  • All databases dumped
  • Compressed with gzip (typically 10-20% of original)
  • Automatic rotation (keeps only 7 days)
  • Detailed logging
  • Error handling
  • No manual intervention needed

Example:

mariadb_all_databases_20251116_020000.sql.gz  32M
mariadb_all_databases_20251115_020000.sql.gz  31M
mariadb_all_databases_20251114_020000.sql.gz  33M
mariadb_all_databases_20251113_020000.sql.gz  29M
mariadb_all_databases_20251112_020000.sql.gz  30M
mariadb_all_databases_20251111_020000.sql.gz  32M
mariadb_all_databases_20251110_020000.sql.gz  31M

🧪 Test Manually

source /mnt/HC_Volume_103713257/tilbudgivern/backend/.env && \
/mnt/HC_Volume_103713257/tilbudgivern/scripts/backup-databases.sh

📊 Monitor

View backups:

ls -lh /mnt/HC_Volume_103713257/tilbudgivern/backups/

View logs:

tail -f /mnt/HC_Volume_103713257/tilbudgivern/logs/backups/backup.log

Check crontab:

sudo crontab -l | grep backup

🔧 Available Commands

Command Purpose
bash setup-backups.sh Automated setup (choose schedule, install logrotate)
bash backup-databases.sh Manual backup run
ls -lh backups/ See all backups
tail -f logs/backups/backup.log Monitor backup logs in real-time
sudo crontab -l View current crontab

📖 Full Documentation

See: /mnt/HC_Volume_103713257/tilbudgivern/docs/DATABASE_BACKUP_SETUP.md

For troubleshooting, recovery, and advanced configuration.