# 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 ```bash 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`: ```bash nano /mnt/HC_Volume_103713257/tilbudgivern/backend/.env ``` Add: ```env 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 ```bash source /mnt/HC_Volume_103713257/tilbudgivern/backend/.env && \ /mnt/HC_Volume_103713257/tilbudgivern/scripts/backup-databases.sh ``` --- ## ๐Ÿ“Š Monitor **View backups:** ```bash ls -lh /mnt/HC_Volume_103713257/tilbudgivern/backups/ ``` **View logs:** ```bash tail -f /mnt/HC_Volume_103713257/tilbudgivern/logs/backups/backup.log ``` **Check crontab:** ```bash 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.