Backups
Regular backups are essential for protecting your LearnHouse data. The LearnHouse CLI provides built-in backup and restore functionality.
Creating a Backup
Create a backup with a single command:
learnhouse backupThis creates a timestamped archive file containing:
- PostgreSQL database dump — all users, courses, organizations, and configuration data
- Uploaded content — images, videos, documents, and other files stored on the filesystem
The backup file is saved in the current working directory with a name like backup-2025-01-15-120000.tar.gz.
Restoring from a Backup
To restore from a backup file:
learnhouse restore backup-2025-01-15-120000.tar.gzThe restore process:
- Stops all running services
- Restores the database from the dump
- Restores uploaded content files
- Restarts all services
Restoring a backup overwrites all current data. Make sure you are restoring to the correct instance.
Automating Backups
It is recommended to set up automated backups using a cron job. For example, to create a daily backup at 2:00 AM:
# Edit your crontab
crontab -e
# Add this line for daily backups at 2 AM
0 2 * * * /usr/local/bin/learnhouse backupBackup Retention
Backup files can accumulate over time and consume significant disk space. Implement a retention policy to remove old backups. For example, keep the last 7 daily backups:
# Remove backups older than 7 days
find /path/to/backups -name "backup-*.tar.gz" -mtime +7 -deleteS3 Storage Considerations
If you use S3-compatible storage for uploaded content, the learnhouse backup command backs up the database only. Your S3 content is managed by your storage provider, which typically offers its own backup and versioning features.
For S3-based deployments, ensure your storage provider’s backup or versioning features are enabled to protect uploaded content.