commit a2adb89d936e5d441c82372c4091742c2c864490 Author: Aodhan Collins Date: Mon Sep 8 01:03:45 2025 +0100 Initial commit diff --git a/.env b/.env new file mode 100644 index 0000000..185d9a7 --- /dev/null +++ b/.env @@ -0,0 +1,13 @@ +# Database Configuration +# Generate a secure password for your database +# You can use: openssl rand -base64 32 +DB_PASSWORD=your_secure_database_password_here + +# Wiki.js Configuration +# The domain where your wiki will be accessible +# For local development, use localhost:3000 +# For production, use your actual domain +WIKI_URL=http://localhost:3000 + +# Optional: Set timezone (default is UTC) +TZ=Europe/London diff --git a/README.md b/README.md new file mode 100644 index 0000000..2835ac4 --- /dev/null +++ b/README.md @@ -0,0 +1,155 @@ +# Personal Wiki.js Setup for Home Server + +This repository contains everything you need to set up your personal Wiki.js instance on your home server. + +## ๐Ÿš€ Quick Start + +1. **Run the setup script:** + ```bash + ./setup.sh + ``` + +2. **Access your wiki:** + - Open http://localhost:3000 in your browser + - Complete the initial setup wizard + - Create your administrator account + +## ๐Ÿ“ Project Structure + +``` +wikiaodh/ +โ”œโ”€โ”€ docker-compose.yml # Docker services configuration +โ”œโ”€โ”€ .env # Environment variables (passwords, etc.) +โ”œโ”€โ”€ setup.sh # Automated setup script +โ”œโ”€โ”€ README.md # This file +โ””โ”€โ”€ data/ # Created automatically for persistent data + โ”œโ”€โ”€ wiki/ # Wiki application data + โ”œโ”€โ”€ db/ # PostgreSQL database files + โ””โ”€โ”€ assets/ # Uploaded media and assets +``` + +## ๐Ÿ”ง Configuration + +### Environment Variables (.env) +- `DB_PASSWORD`: Secure password for PostgreSQL database +- `WIKI_URL`: The URL where your wiki will be accessible +- `TZ`: Your timezone (default: Europe/London) + +### Ports +- **3000**: Wiki.js web interface (http://localhost:3000) +- **5432**: PostgreSQL database (internal only) + +## ๐Ÿ“‹ Management Commands + +```bash +# Start the wiki +docker-compose up -d + +# Stop the wiki +docker-compose down + +# View logs +docker-compose logs -f + +# Restart services +docker-compose restart + +# Update to latest version +docker-compose pull +docker-compose up -d +``` + +## ๐Ÿ’พ Backup & Restore + +### Backup +```bash +# Backup database +docker-compose exec db pg_dump -U wikijs wiki > backup_$(date +%Y%m%d).sql + +# Backup uploaded files +tar -czf assets_backup_$(date +%Y%m%d).tar.gz data/assets/ +``` + +### Restore +```bash +# Restore database +docker-compose exec -T db psql -U wikijs wiki < backup_YYYYMMDD.sql + +# Restore uploaded files +tar -xzf assets_backup_YYYYMMDD.tar.gz +``` + +## ๐Ÿ”’ Security Considerations + +1. **Change default passwords**: The setup script generates a secure database password automatically +2. **Firewall**: Consider restricting access to port 3000 to your local network only +3. **HTTPS**: For production use, set up a reverse proxy with SSL/TLS +4. **Regular updates**: Keep Docker images updated with `docker-compose pull` + +## ๐ŸŒ Accessing from Other Devices + +To access your wiki from other devices on your network: + +1. Find your server's IP address: `ip addr show` +2. Update the `WIKI_URL` in `.env` to use your server's IP +3. Access via `http://YOUR_SERVER_IP:3000` + +## ๐Ÿ“š Wiki.js Features + +Your personal wiki includes: + +- **Rich Text Editor**: WYSIWYG and Markdown support +- **Media Management**: Upload and organize images, documents, videos +- **Search**: Full-text search across all content +- **User Management**: Create accounts for family members or team +- **Themes**: Light and dark mode support +- **Mobile Friendly**: Responsive design for all devices +- **Version History**: Track changes to all pages +- **Categories & Tags**: Organize content efficiently + +## ๐Ÿ†˜ Troubleshooting + +### Wiki won't start +```bash +# Check logs +docker-compose logs + +# Restart services +docker-compose down +docker-compose up -d +``` + +### Database connection issues +```bash +# Reset database +docker-compose down +docker volume rm wikiaodh_db-data +docker-compose up -d +``` + +### Permission issues +```bash +# Fix permissions +sudo chown -R $USER:$USER data/ +chmod -R 755 data/ +``` + +## ๐Ÿ”„ Updates + +To update Wiki.js to the latest version: + +```bash +docker-compose down +docker-compose pull +docker-compose up -d +``` + +## ๐Ÿ“ž Support + +- [Wiki.js Documentation](https://docs.js.wiki/) +- [Wiki.js GitHub](https://github.com/Requarks/wiki) +- [Docker Compose Documentation](https://docs.docker.com/compose/) + +--- + +**Enjoy your personal wiki! ๐Ÿ“–โœจ** diff --git a/backup.sh b/backup.sh new file mode 100755 index 0000000..cd90c72 --- /dev/null +++ b/backup.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# Wiki.js Backup Script +# Creates backups of your wiki database and uploaded assets + +set -e + +BACKUP_DIR="backups" +DATE=$(date +%Y%m%d_%H%M%S) + +echo "๐Ÿ”„ Starting Wiki.js backup..." + +# Create backup directory if it doesn't exist +mkdir -p "$BACKUP_DIR" + +# Check if services are running +if ! docker-compose ps | grep -q "Up"; then + echo "โŒ Wiki.js services are not running. Please start them first with: docker-compose up -d" + exit 1 +fi + +echo "๐Ÿ’พ Backing up database..." +# Backup PostgreSQL database +docker-compose exec -T db pg_dump -U wikijs wiki > "$BACKUP_DIR/wiki_db_$DATE.sql" + +echo "๐Ÿ“ Backing up assets and data..." +# Backup uploaded assets and wiki data +tar -czf "$BACKUP_DIR/wiki_assets_$DATE.tar.gz" -C data assets wiki 2>/dev/null || true + +# Backup configuration files +echo "โš™๏ธ Backing up configuration..." +tar -czf "$BACKUP_DIR/wiki_config_$DATE.tar.gz" docker-compose.yml .env README.md 2>/dev/null || true + +echo "โœ… Backup completed successfully!" +echo "๐Ÿ“‚ Backup files created:" +echo " - Database: $BACKUP_DIR/wiki_db_$DATE.sql" +echo " - Assets: $BACKUP_DIR/wiki_assets_$DATE.tar.gz" +echo " - Config: $BACKUP_DIR/wiki_config_$DATE.tar.gz" + +# Clean up old backups (keep last 7 days) +echo "๐Ÿงน Cleaning up old backups (keeping last 7 days)..." +find "$BACKUP_DIR" -name "wiki_*" -type f -mtime +7 -delete 2>/dev/null || true + +echo "๐ŸŽ‰ Backup process complete!" diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..2dd1010 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,49 @@ +version: '3.8' + +services: + wiki: + image: ghcr.io/requarks/wiki:2 + container_name: wikiaodh + depends_on: + - db + environment: + DB_TYPE: postgres + DB_HOST: db + DB_PORT: 5432 + DB_USER: wikijs + DB_PASS: ${DB_PASSWORD} + DB_NAME: wiki + UPGRADE_COMPANION: 1 + restart: unless-stopped + ports: + - "3000:3000" + volumes: + - wiki-data:/wiki/data + - wiki-assets:/wiki/assets + networks: + - wiki-network + + db: + image: postgres:15-alpine + container_name: wikiaodh-db + environment: + POSTGRES_DB: wiki + POSTGRES_USER: wikijs + POSTGRES_PASSWORD: ${DB_PASSWORD} + restart: unless-stopped + volumes: + - db-data:/var/lib/postgresql/data + networks: + - wiki-network + +volumes: + wiki-data: + driver: local + wiki-assets: + driver: local + db-data: + driver: local + +networks: + wiki-network: + driver: bridge diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000..b5baa26 --- /dev/null +++ b/setup.sh @@ -0,0 +1,79 @@ +#!/bin/bash + +# Wiki.js Setup Script for Home Server +# This script helps you set up your personal Wiki.js instance + +set -e + +echo "๐Ÿš€ Setting up Wiki.js for your home server..." + +# Check if Docker is installed +if ! command -v docker &> /dev/null; then + echo "โŒ Docker is not installed. Please install Docker first." + echo "Visit: https://docs.docker.com/engine/install/" + exit 1 +fi + +# Check if Docker Compose is installed +if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null; then + echo "โŒ Docker Compose is not installed. Please install Docker Compose first." + echo "Visit: https://docs.docker.com/compose/install/" + exit 1 +fi + +# Generate a secure database password if not already set +if [ ! -f .env ]; then + echo "โŒ .env file not found. Please create it first." + exit 1 +fi + +# Check if password is still the default +if grep -q "your_secure_database_password_here" .env; then + echo "๐Ÿ” Generating secure database password..." + SECURE_PASSWORD=$(openssl rand -base64 32) + sed -i "s/your_secure_database_password_here/$SECURE_PASSWORD/g" .env + echo "โœ… Secure password generated and saved to .env" +fi + +# Create necessary directories +echo "๐Ÿ“ Creating data directories..." +mkdir -p data/wiki +mkdir -p data/db +mkdir -p data/assets + +# Set proper permissions +echo "๐Ÿ”ง Setting permissions..." +chmod 755 data/wiki data/db data/assets + +# Pull the latest images +echo "๐Ÿ“ฅ Pulling Docker images..." +docker-compose pull + +# Start the services +echo "๐Ÿƒ Starting Wiki.js services..." +docker-compose up -d + +# Wait for services to be ready +echo "โณ Waiting for services to start..." +sleep 10 + +# Check if services are running +if docker-compose ps | grep -q "Up"; then + echo "โœ… Wiki.js is starting up!" + echo "" + echo "๐ŸŒ Your wiki will be available at: http://localhost:3000" + echo "โฐ Please wait 1-2 minutes for the initial setup to complete." + echo "" + echo "๐Ÿ“‹ Next steps:" + echo "1. Open http://localhost:3000 in your browser" + echo "2. Complete the initial setup wizard" + echo "3. Create your administrator account" + echo "4. Start adding content to your personal wiki!" + echo "" + echo "๐Ÿ“Š To check status: docker-compose logs -f" + echo "๐Ÿ›‘ To stop: docker-compose down" + echo "๐Ÿ”„ To restart: docker-compose restart" +else + echo "โŒ Something went wrong. Check the logs with: docker-compose logs" + exit 1 +fi