bMINI
This commit is contained in:
80
.gitignore
vendored
80
.gitignore
vendored
@@ -1,40 +1,40 @@
|
||||
# Gitea data directory
|
||||
data/
|
||||
|
||||
# Database files
|
||||
*.db
|
||||
*.sqlite
|
||||
|
||||
# Log files
|
||||
*.log
|
||||
|
||||
# Environment files
|
||||
.env
|
||||
|
||||
# System files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Docker volumes
|
||||
volumes/
|
||||
|
||||
# Gitea directories
|
||||
gitea/*
|
||||
!gitea/ssl/
|
||||
!gitea/conf/
|
||||
|
||||
# SSL certificates (should not be in version control)
|
||||
gitea/ssl/*.pem
|
||||
gitea/ssl/*.key
|
||||
gitea/ssl/*.crt
|
||||
|
||||
# Gitea user data and logs
|
||||
gitea/gitea/*
|
||||
gitea/git/*
|
||||
gitea/ssh/*
|
||||
gitea/data/*
|
||||
|
||||
# Temporary files
|
||||
*.tmp
|
||||
*.temp
|
||||
*~
|
||||
# Gitea data directory
|
||||
data/
|
||||
|
||||
# Database files
|
||||
*.db
|
||||
*.sqlite
|
||||
|
||||
# Log files
|
||||
*.log
|
||||
|
||||
# Environment files
|
||||
.env
|
||||
|
||||
# System files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Docker volumes
|
||||
volumes/
|
||||
|
||||
# Gitea directories
|
||||
gitea/*
|
||||
!gitea/ssl/
|
||||
!gitea/conf/
|
||||
|
||||
# SSL certificates (should not be in version control)
|
||||
gitea/ssl/*.pem
|
||||
gitea/ssl/*.key
|
||||
gitea/ssl/*.crt
|
||||
|
||||
# Gitea user data and logs
|
||||
gitea/gitea/*
|
||||
gitea/git/*
|
||||
gitea/ssh/*
|
||||
gitea/data/*
|
||||
|
||||
# Temporary files
|
||||
*.tmp
|
||||
*.temp
|
||||
*~
|
||||
|
||||
144
BACKUP-README.md
144
BACKUP-README.md
@@ -1,73 +1,73 @@
|
||||
# Gitea Backup Strategy
|
||||
|
||||
This document outlines the backup strategy for your Gitea installation, focusing on ensuring your database is always backed up in at least one place.
|
||||
|
||||
## Backup Methods
|
||||
|
||||
This setup provides two complementary backup methods:
|
||||
|
||||
### 1. PostgreSQL Database Dumps
|
||||
|
||||
Database dumps are SQL files containing all your database data. These are the most reliable way to back up a PostgreSQL database.
|
||||
|
||||
- **Script**: `backup-gitea-db.ps1`
|
||||
- **Output**: SQL dumps in the `backups` directory, compressed as ZIP files
|
||||
- **Retention**: Keeps the last 10 backups by default
|
||||
|
||||
### 2. Docker Volume Backups
|
||||
|
||||
This method backs up the entire PostgreSQL data volume, which includes all database files.
|
||||
|
||||
- **Script**: `backup-volume.ps1`
|
||||
- **Output**: TAR archives in the `backups` directory, compressed as ZIP files
|
||||
- **Retention**: Keeps the last 5 volume backups by default
|
||||
|
||||
## Automated Backups
|
||||
|
||||
You can set up automated daily backups using the included script:
|
||||
|
||||
```powershell
|
||||
.\schedule-backup.ps1
|
||||
```
|
||||
|
||||
This creates a Windows Scheduled Task that runs the database backup script daily at 3 AM.
|
||||
|
||||
## Restoring from Backups
|
||||
|
||||
### Restoring from a Database Dump
|
||||
|
||||
```powershell
|
||||
.\restore-gitea-db.ps1 -BackupFile "backups\gitea-db-backup-2025-03-01_10-30-00.sql.zip"
|
||||
```
|
||||
|
||||
### Restoring from a Volume Backup
|
||||
|
||||
```powershell
|
||||
.\restore-volume.ps1 -BackupFile "backups\postgres-volume-backup-2025-03-01_10-30-00.tar.zip"
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Regular Backups**: Run backups at least daily
|
||||
2. **Multiple Backup Methods**: Use both database dumps and volume backups
|
||||
3. **Off-site Storage**: Copy your backups to an external drive or cloud storage
|
||||
4. **Test Restores**: Periodically test restoring from your backups
|
||||
5. **Version Control**: Keep your Gitea configuration files in version control
|
||||
|
||||
## Important Notes
|
||||
|
||||
- **Never** run `docker-compose down -v` unless you have a recent backup
|
||||
- When upgrading Gitea, always create a backup first
|
||||
- The database volume (`postgres-data`) persists even when containers are stopped or removed, but can be lost if explicitly deleted
|
||||
|
||||
## Manual Backup Commands
|
||||
|
||||
If you need to create a backup manually:
|
||||
|
||||
```powershell
|
||||
# Database dump
|
||||
.\backup-gitea-db.ps1
|
||||
|
||||
# Volume backup
|
||||
.\backup-volume.ps1
|
||||
# Gitea Backup Strategy
|
||||
|
||||
This document outlines the backup strategy for your Gitea installation, focusing on ensuring your database is always backed up in at least one place.
|
||||
|
||||
## Backup Methods
|
||||
|
||||
This setup provides two complementary backup methods:
|
||||
|
||||
### 1. PostgreSQL Database Dumps
|
||||
|
||||
Database dumps are SQL files containing all your database data. These are the most reliable way to back up a PostgreSQL database.
|
||||
|
||||
- **Script**: `backup-gitea-db.ps1`
|
||||
- **Output**: SQL dumps in the `backups` directory, compressed as ZIP files
|
||||
- **Retention**: Keeps the last 10 backups by default
|
||||
|
||||
### 2. Docker Volume Backups
|
||||
|
||||
This method backs up the entire PostgreSQL data volume, which includes all database files.
|
||||
|
||||
- **Script**: `backup-volume.ps1`
|
||||
- **Output**: TAR archives in the `backups` directory, compressed as ZIP files
|
||||
- **Retention**: Keeps the last 5 volume backups by default
|
||||
|
||||
## Automated Backups
|
||||
|
||||
You can set up automated daily backups using the included script:
|
||||
|
||||
```powershell
|
||||
.\schedule-backup.ps1
|
||||
```
|
||||
|
||||
This creates a Windows Scheduled Task that runs the database backup script daily at 3 AM.
|
||||
|
||||
## Restoring from Backups
|
||||
|
||||
### Restoring from a Database Dump
|
||||
|
||||
```powershell
|
||||
.\restore-gitea-db.ps1 -BackupFile "backups\gitea-db-backup-2025-03-01_10-30-00.sql.zip"
|
||||
```
|
||||
|
||||
### Restoring from a Volume Backup
|
||||
|
||||
```powershell
|
||||
.\restore-volume.ps1 -BackupFile "backups\postgres-volume-backup-2025-03-01_10-30-00.tar.zip"
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Regular Backups**: Run backups at least daily
|
||||
2. **Multiple Backup Methods**: Use both database dumps and volume backups
|
||||
3. **Off-site Storage**: Copy your backups to an external drive or cloud storage
|
||||
4. **Test Restores**: Periodically test restoring from your backups
|
||||
5. **Version Control**: Keep your Gitea configuration files in version control
|
||||
|
||||
## Important Notes
|
||||
|
||||
- **Never** run `docker-compose down -v` unless you have a recent backup
|
||||
- When upgrading Gitea, always create a backup first
|
||||
- The database volume (`postgres-data`) persists even when containers are stopped or removed, but can be lost if explicitly deleted
|
||||
|
||||
## Manual Backup Commands
|
||||
|
||||
If you need to create a backup manually:
|
||||
|
||||
```powershell
|
||||
# Database dump
|
||||
.\backup-gitea-db.ps1
|
||||
|
||||
# Volume backup
|
||||
.\backup-volume.ps1
|
||||
```
|
||||
160
HTTPS-SETUP.md
160
HTTPS-SETUP.md
@@ -1,81 +1,81 @@
|
||||
# Setting Up HTTPS for Gitea with Traefik
|
||||
|
||||
This guide explains how to configure Gitea with proper HTTPS using Traefik as a reverse proxy with automatic certificate management via Let's Encrypt.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- A domain name pointing to your server (currently using `bee8333.ddns.net`)
|
||||
- Ports 80 and 443 open and forwarded to your server
|
||||
- Docker and Docker Compose installed
|
||||
|
||||
## Configuration Steps
|
||||
|
||||
1. **Update email address in docker-compose.yml**
|
||||
|
||||
Edit the `docker-compose.yml` file and replace `your-email@example.com` with your actual email address. Let's Encrypt will use this for certificate expiration notifications:
|
||||
|
||||
```yaml
|
||||
--certificatesresolvers.letsencrypt.acme.email=your-email@example.com
|
||||
```
|
||||
|
||||
2. **Start the services**
|
||||
|
||||
```bash
|
||||
docker-compose down
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
3. **Check the status**
|
||||
|
||||
```bash
|
||||
docker-compose ps
|
||||
```
|
||||
|
||||
All services should be running without errors.
|
||||
|
||||
## How It Works
|
||||
|
||||
- **Traefik** acts as a reverse proxy, handling incoming HTTP/HTTPS traffic
|
||||
- Automatically redirects HTTP to HTTPS
|
||||
- Obtains and renews SSL certificates from Let's Encrypt
|
||||
- Routes requests to the appropriate containers based on domain name
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
If you encounter issues:
|
||||
|
||||
1. **Check Traefik logs**
|
||||
|
||||
```bash
|
||||
docker-compose logs traefik
|
||||
```
|
||||
|
||||
2. **Check Gitea logs**
|
||||
|
||||
```bash
|
||||
docker-compose logs server
|
||||
```
|
||||
|
||||
3. **Verify DNS settings**
|
||||
|
||||
Make sure your domain (`bee8333.ddns.net`) correctly points to your server's IP address.
|
||||
|
||||
4. **Check firewall settings**
|
||||
|
||||
Ensure ports 80 and 443 are open and properly forwarded to your server.
|
||||
|
||||
## Git Client Configuration
|
||||
|
||||
When pushing to your Gitea repository from your local machine, you'll now be using HTTPS with a valid certificate. Use the following URL format:
|
||||
|
||||
```
|
||||
https://bee8333.ddns.net/username/repository.git
|
||||
```
|
||||
|
||||
## SSH Access
|
||||
|
||||
SSH access is still available on port 222. Use the following format in your SSH config or Git command:
|
||||
|
||||
```
|
||||
ssh://git@bee8333.ddns.net:222/username/repository.git
|
||||
# Setting Up HTTPS for Gitea with Traefik
|
||||
|
||||
This guide explains how to configure Gitea with proper HTTPS using Traefik as a reverse proxy with automatic certificate management via Let's Encrypt.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- A domain name pointing to your server (currently using `bee8333.ddns.net`)
|
||||
- Ports 80 and 443 open and forwarded to your server
|
||||
- Docker and Docker Compose installed
|
||||
|
||||
## Configuration Steps
|
||||
|
||||
1. **Update email address in docker-compose.yml**
|
||||
|
||||
Edit the `docker-compose.yml` file and replace `your-email@example.com` with your actual email address. Let's Encrypt will use this for certificate expiration notifications:
|
||||
|
||||
```yaml
|
||||
--certificatesresolvers.letsencrypt.acme.email=your-email@example.com
|
||||
```
|
||||
|
||||
2. **Start the services**
|
||||
|
||||
```bash
|
||||
docker-compose down
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
3. **Check the status**
|
||||
|
||||
```bash
|
||||
docker-compose ps
|
||||
```
|
||||
|
||||
All services should be running without errors.
|
||||
|
||||
## How It Works
|
||||
|
||||
- **Traefik** acts as a reverse proxy, handling incoming HTTP/HTTPS traffic
|
||||
- Automatically redirects HTTP to HTTPS
|
||||
- Obtains and renews SSL certificates from Let's Encrypt
|
||||
- Routes requests to the appropriate containers based on domain name
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
If you encounter issues:
|
||||
|
||||
1. **Check Traefik logs**
|
||||
|
||||
```bash
|
||||
docker-compose logs traefik
|
||||
```
|
||||
|
||||
2. **Check Gitea logs**
|
||||
|
||||
```bash
|
||||
docker-compose logs server
|
||||
```
|
||||
|
||||
3. **Verify DNS settings**
|
||||
|
||||
Make sure your domain (`bee8333.ddns.net`) correctly points to your server's IP address.
|
||||
|
||||
4. **Check firewall settings**
|
||||
|
||||
Ensure ports 80 and 443 are open and properly forwarded to your server.
|
||||
|
||||
## Git Client Configuration
|
||||
|
||||
When pushing to your Gitea repository from your local machine, you'll now be using HTTPS with a valid certificate. Use the following URL format:
|
||||
|
||||
```
|
||||
https://bee8333.ddns.net/username/repository.git
|
||||
```
|
||||
|
||||
## SSH Access
|
||||
|
||||
SSH access is still available on port 222. Use the following format in your SSH config or Git command:
|
||||
|
||||
```
|
||||
ssh://git@bee8333.ddns.net:222/username/repository.git
|
||||
```
|
||||
364
README.md
364
README.md
@@ -1,183 +1,183 @@
|
||||
# Gitea Docker Setup
|
||||
|
||||
This is a Docker Compose configuration for running Gitea with PostgreSQL, configured with HTTPS support.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Docker Desktop for Windows
|
||||
- Docker Compose
|
||||
- A domain or DDNS service (configured to point to your server)
|
||||
- Port forwarding configured on your router (if accessing from outside your network)
|
||||
|
||||
## Features
|
||||
|
||||
- Gitea with HTTPS support
|
||||
- PostgreSQL database
|
||||
- SSH access for Git operations
|
||||
- Persistent data storage
|
||||
- Self-signed SSL certificates (can be replaced with Let's Encrypt)
|
||||
- Automated database backup system
|
||||
|
||||
## Configuration
|
||||
|
||||
The setup includes:
|
||||
- Gitea web interface:
|
||||
- External access: https://bee8333.ddns.net/
|
||||
- Local network access: https://bee8333.ddns.net/ or https://localhost:3000
|
||||
- Local development: https://127.0.0.1:3000
|
||||
- SSH access on port 222 (for git clone/push/pull)
|
||||
- PostgreSQL database (internal access only)
|
||||
- SSL certificates in `./gitea/ssl/`
|
||||
- Persistent data storage for both Gitea and PostgreSQL
|
||||
|
||||
## Access Methods
|
||||
|
||||
### Web Interface
|
||||
|
||||
1. **External Access (Internet)**:
|
||||
- URL: https://bee8333.ddns.net/
|
||||
- Requires port 3000 forwarded on your router
|
||||
- Uses HTTPS with SSL certificate
|
||||
|
||||
2. **Local Network Access**:
|
||||
- Same URL: https://bee8333.ddns.net/
|
||||
- Or use: https://localhost:3000
|
||||
- Both use HTTPS with SSL certificate
|
||||
- No port forwarding needed
|
||||
|
||||
3. **Local Development**:
|
||||
- URL: https://127.0.0.1:3000
|
||||
- Direct access on the hosting machine
|
||||
- Uses HTTPS with SSL certificate
|
||||
|
||||
### Git Operations (SSH)
|
||||
|
||||
- External SSH URL: `ssh://git@bee8333.ddns.net:222/username/repository.git`
|
||||
- Local SSH URL: `ssh://git@localhost:222/username/repository.git`
|
||||
- Requires port 222 forwarded on your router for external access
|
||||
|
||||
## Getting Started
|
||||
|
||||
1. Make sure Docker Desktop is running
|
||||
2. Clone this repository
|
||||
3. Open a terminal in this directory
|
||||
4. Generate SSL certificates (see [SSL Certificates](#ssl-certificates) section)
|
||||
5. Run `docker-compose up -d`
|
||||
6. Access Gitea using one of the URLs above
|
||||
7. During first-time setup:
|
||||
- Database settings are pre-configured (no changes needed)
|
||||
- Domain is set to your domain name
|
||||
- SSH port is set to 222
|
||||
- HTTPS is enabled by default
|
||||
|
||||
## SSL Certificates
|
||||
|
||||
You'll need to generate SSL certificates before starting the service. The certificates should be placed in `./gitea/ssl/`:
|
||||
- `cert.pem` - The SSL certificate
|
||||
- `key.pem` - The private key
|
||||
|
||||
To generate self-signed certificates (for development/testing):
|
||||
|
||||
```bash
|
||||
# Create the ssl directory
|
||||
mkdir -p gitea/ssl
|
||||
|
||||
# Generate certificates using OpenSSL
|
||||
docker run --rm -v ${PWD}/gitea/ssl:/ssl alpine/openssl req -x509 -nodes \
|
||||
-days 365 -newkey rsa:2048 \
|
||||
-keyout /ssl/key.pem -out /ssl/cert.pem \
|
||||
-subj "/CN=your.domain.here"
|
||||
```
|
||||
|
||||
Replace `your.domain.here` with your actual domain name.
|
||||
|
||||
**Security Notes:**
|
||||
- Never commit SSL certificates to version control
|
||||
- Keep your private key (key.pem) secure
|
||||
- For production use, consider using Let's Encrypt certificates
|
||||
- Self-signed certificates will show browser security warnings
|
||||
|
||||
## Backup System
|
||||
|
||||
This setup includes a comprehensive backup strategy to ensure your Gitea data is always protected. The backup system provides two complementary methods:
|
||||
|
||||
### Database Backups
|
||||
|
||||
PowerShell scripts are included to manage database backups:
|
||||
|
||||
1. **Creating Backups**:
|
||||
```powershell
|
||||
powershell -ExecutionPolicy Bypass -File .\backup-gitea-db.ps1
|
||||
```
|
||||
This creates a SQL dump of your PostgreSQL database, compressed as a ZIP file in the `backups` directory.
|
||||
|
||||
2. **Volume Backups**:
|
||||
```powershell
|
||||
powershell -ExecutionPolicy Bypass -File .\backup-volume.ps1
|
||||
```
|
||||
This backs up the entire PostgreSQL data volume as a TAR archive, compressed as a ZIP file.
|
||||
|
||||
3. **Automated Backups**:
|
||||
```powershell
|
||||
powershell -ExecutionPolicy Bypass -File .\schedule-backup.ps1
|
||||
```
|
||||
This creates a Windows Scheduled Task that runs database backups daily at 3 AM.
|
||||
|
||||
4. **Restoring from Backups**:
|
||||
```powershell
|
||||
# Restore from database dump
|
||||
powershell -ExecutionPolicy Bypass -File .\restore-gitea-db.ps1 -BackupFile "backups\your-backup-file.sql.zip"
|
||||
|
||||
# Restore from volume backup
|
||||
powershell -ExecutionPolicy Bypass -File .\restore-volume.ps1 -BackupFile "backups\your-volume-backup.tar.zip"
|
||||
```
|
||||
|
||||
### Backup Best Practices
|
||||
|
||||
- Keep multiple backups using both methods (database dumps and volume backups)
|
||||
- Store backups in multiple locations (local and off-site)
|
||||
- Test restoring from backups periodically
|
||||
- Create a backup before upgrading Gitea or making significant changes
|
||||
- **Never** run `docker-compose down -v` unless you have a recent backup
|
||||
|
||||
For more detailed information about the backup system, see [BACKUP-README.md](BACKUP-README.md).
|
||||
|
||||
## Stopping the Services
|
||||
|
||||
To stop the services, run:
|
||||
```bash
|
||||
docker-compose down
|
||||
```
|
||||
|
||||
**Important**: Do not use the `-v` flag (`docker-compose down -v`) unless you intend to delete all data, as this will remove the Docker volumes containing your database.
|
||||
|
||||
## Data Persistence
|
||||
|
||||
All data is stored in Docker volumes and local directories:
|
||||
- `./gitea/` - Gitea configuration and data
|
||||
- `./gitea/ssl/` - SSL certificates
|
||||
- `./gitea/conf/` - Gitea configuration
|
||||
- Docker volumes (managed by Docker):
|
||||
- `gitea-data` - Gitea repositories and application data
|
||||
- `postgres-data` - PostgreSQL database files
|
||||
- `./backups/` - Database and volume backups
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
1. **Cannot access externally**:
|
||||
- Verify port 3000 (HTTP) and 222 (SSH) are forwarded on your router
|
||||
- Check your DDNS service is updating correctly
|
||||
- Ensure your domain points to your correct IP
|
||||
|
||||
2. **SSL Certificate Warnings**:
|
||||
- This is normal with self-signed certificates
|
||||
- For production, consider using Let's Encrypt certificates
|
||||
|
||||
3. **Local Network Access**:
|
||||
- If bee8333.ddns.net doesn't resolve locally, use localhost:3000 instead
|
||||
- Add an entry to your hosts file if needed
|
||||
|
||||
4. **Database Backup Issues**:
|
||||
- Ensure Docker is running when attempting backups
|
||||
- Check that the container names match those in the backup scripts
|
||||
# Gitea Docker Setup
|
||||
|
||||
This is a Docker Compose configuration for running Gitea with PostgreSQL, configured with HTTPS support.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Docker Desktop for Windows
|
||||
- Docker Compose
|
||||
- A domain or DDNS service (configured to point to your server)
|
||||
- Port forwarding configured on your router (if accessing from outside your network)
|
||||
|
||||
## Features
|
||||
|
||||
- Gitea with HTTPS support
|
||||
- PostgreSQL database
|
||||
- SSH access for Git operations
|
||||
- Persistent data storage
|
||||
- Self-signed SSL certificates (can be replaced with Let's Encrypt)
|
||||
- Automated database backup system
|
||||
|
||||
## Configuration
|
||||
|
||||
The setup includes:
|
||||
- Gitea web interface:
|
||||
- External access: https://bee8333.ddns.net/
|
||||
- Local network access: https://bee8333.ddns.net/ or https://localhost:3000
|
||||
- Local development: https://127.0.0.1:3000
|
||||
- SSH access on port 222 (for git clone/push/pull)
|
||||
- PostgreSQL database (internal access only)
|
||||
- SSL certificates in `./gitea/ssl/`
|
||||
- Persistent data storage for both Gitea and PostgreSQL
|
||||
|
||||
## Access Methods
|
||||
|
||||
### Web Interface
|
||||
|
||||
1. **External Access (Internet)**:
|
||||
- URL: https://bee8333.ddns.net/
|
||||
- Requires port 3000 forwarded on your router
|
||||
- Uses HTTPS with SSL certificate
|
||||
|
||||
2. **Local Network Access**:
|
||||
- Same URL: https://bee8333.ddns.net/
|
||||
- Or use: https://localhost:3000
|
||||
- Both use HTTPS with SSL certificate
|
||||
- No port forwarding needed
|
||||
|
||||
3. **Local Development**:
|
||||
- URL: https://127.0.0.1:3000
|
||||
- Direct access on the hosting machine
|
||||
- Uses HTTPS with SSL certificate
|
||||
|
||||
### Git Operations (SSH)
|
||||
|
||||
- External SSH URL: `ssh://git@bee8333.ddns.net:222/username/repository.git`
|
||||
- Local SSH URL: `ssh://git@localhost:222/username/repository.git`
|
||||
- Requires port 222 forwarded on your router for external access
|
||||
|
||||
## Getting Started
|
||||
|
||||
1. Make sure Docker Desktop is running
|
||||
2. Clone this repository
|
||||
3. Open a terminal in this directory
|
||||
4. Generate SSL certificates (see [SSL Certificates](#ssl-certificates) section)
|
||||
5. Run `docker-compose up -d`
|
||||
6. Access Gitea using one of the URLs above
|
||||
7. During first-time setup:
|
||||
- Database settings are pre-configured (no changes needed)
|
||||
- Domain is set to your domain name
|
||||
- SSH port is set to 222
|
||||
- HTTPS is enabled by default
|
||||
|
||||
## SSL Certificates
|
||||
|
||||
You'll need to generate SSL certificates before starting the service. The certificates should be placed in `./gitea/ssl/`:
|
||||
- `cert.pem` - The SSL certificate
|
||||
- `key.pem` - The private key
|
||||
|
||||
To generate self-signed certificates (for development/testing):
|
||||
|
||||
```bash
|
||||
# Create the ssl directory
|
||||
mkdir -p gitea/ssl
|
||||
|
||||
# Generate certificates using OpenSSL
|
||||
docker run --rm -v ${PWD}/gitea/ssl:/ssl alpine/openssl req -x509 -nodes \
|
||||
-days 365 -newkey rsa:2048 \
|
||||
-keyout /ssl/key.pem -out /ssl/cert.pem \
|
||||
-subj "/CN=your.domain.here"
|
||||
```
|
||||
|
||||
Replace `your.domain.here` with your actual domain name.
|
||||
|
||||
**Security Notes:**
|
||||
- Never commit SSL certificates to version control
|
||||
- Keep your private key (key.pem) secure
|
||||
- For production use, consider using Let's Encrypt certificates
|
||||
- Self-signed certificates will show browser security warnings
|
||||
|
||||
## Backup System
|
||||
|
||||
This setup includes a comprehensive backup strategy to ensure your Gitea data is always protected. The backup system provides two complementary methods:
|
||||
|
||||
### Database Backups
|
||||
|
||||
PowerShell scripts are included to manage database backups:
|
||||
|
||||
1. **Creating Backups**:
|
||||
```powershell
|
||||
powershell -ExecutionPolicy Bypass -File .\backup-gitea-db.ps1
|
||||
```
|
||||
This creates a SQL dump of your PostgreSQL database, compressed as a ZIP file in the `backups` directory.
|
||||
|
||||
2. **Volume Backups**:
|
||||
```powershell
|
||||
powershell -ExecutionPolicy Bypass -File .\backup-volume.ps1
|
||||
```
|
||||
This backs up the entire PostgreSQL data volume as a TAR archive, compressed as a ZIP file.
|
||||
|
||||
3. **Automated Backups**:
|
||||
```powershell
|
||||
powershell -ExecutionPolicy Bypass -File .\schedule-backup.ps1
|
||||
```
|
||||
This creates a Windows Scheduled Task that runs database backups daily at 3 AM.
|
||||
|
||||
4. **Restoring from Backups**:
|
||||
```powershell
|
||||
# Restore from database dump
|
||||
powershell -ExecutionPolicy Bypass -File .\restore-gitea-db.ps1 -BackupFile "backups\your-backup-file.sql.zip"
|
||||
|
||||
# Restore from volume backup
|
||||
powershell -ExecutionPolicy Bypass -File .\restore-volume.ps1 -BackupFile "backups\your-volume-backup.tar.zip"
|
||||
```
|
||||
|
||||
### Backup Best Practices
|
||||
|
||||
- Keep multiple backups using both methods (database dumps and volume backups)
|
||||
- Store backups in multiple locations (local and off-site)
|
||||
- Test restoring from backups periodically
|
||||
- Create a backup before upgrading Gitea or making significant changes
|
||||
- **Never** run `docker-compose down -v` unless you have a recent backup
|
||||
|
||||
For more detailed information about the backup system, see [BACKUP-README.md](BACKUP-README.md).
|
||||
|
||||
## Stopping the Services
|
||||
|
||||
To stop the services, run:
|
||||
```bash
|
||||
docker-compose down
|
||||
```
|
||||
|
||||
**Important**: Do not use the `-v` flag (`docker-compose down -v`) unless you intend to delete all data, as this will remove the Docker volumes containing your database.
|
||||
|
||||
## Data Persistence
|
||||
|
||||
All data is stored in Docker volumes and local directories:
|
||||
- `./gitea/` - Gitea configuration and data
|
||||
- `./gitea/ssl/` - SSL certificates
|
||||
- `./gitea/conf/` - Gitea configuration
|
||||
- Docker volumes (managed by Docker):
|
||||
- `gitea-data` - Gitea repositories and application data
|
||||
- `postgres-data` - PostgreSQL database files
|
||||
- `./backups/` - Database and volume backups
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
1. **Cannot access externally**:
|
||||
- Verify port 3000 (HTTP) and 222 (SSH) are forwarded on your router
|
||||
- Check your DDNS service is updating correctly
|
||||
- Ensure your domain points to your correct IP
|
||||
|
||||
2. **SSL Certificate Warnings**:
|
||||
- This is normal with self-signed certificates
|
||||
- For production, consider using Let's Encrypt certificates
|
||||
|
||||
3. **Local Network Access**:
|
||||
- If bee8333.ddns.net doesn't resolve locally, use localhost:3000 instead
|
||||
- Add an entry to your hosts file if needed
|
||||
|
||||
4. **Database Backup Issues**:
|
||||
- Ensure Docker is running when attempting backups
|
||||
- Check that the container names match those in the backup scripts
|
||||
- For PowerShell execution issues, use the `-ExecutionPolicy Bypass` flag
|
||||
@@ -1,82 +1,82 @@
|
||||
# Gitea Database Backup Script
|
||||
$timestamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
|
||||
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$backupDir = Join-Path $scriptDir "backups"
|
||||
$backupFile = Join-Path $backupDir "gitea-db-backup-$timestamp.sql"
|
||||
$redundantBackupDir = "D:\Pr00jects\gitea-docker"
|
||||
|
||||
# Ensure backup directory exists
|
||||
if (-not (Test-Path $backupDir)) {
|
||||
New-Item -ItemType Directory -Path $backupDir
|
||||
}
|
||||
|
||||
# Ensure redundant backup directory exists
|
||||
if (-not (Test-Path $redundantBackupDir)) {
|
||||
try {
|
||||
New-Item -ItemType Directory -Path $redundantBackupDir -Force
|
||||
} catch {
|
||||
"[$timestamp] Warning: Could not create redundant backup directory at $redundantBackupDir. Error: $_" | Out-File -Append -FilePath $logFile
|
||||
}
|
||||
}
|
||||
|
||||
# Log execution of the script
|
||||
$logFile = Join-Path $backupDir "backup-log.txt"
|
||||
"[$timestamp] Starting database backup..." | Out-File -Append -FilePath $logFile
|
||||
|
||||
# Check if Docker is running
|
||||
$dockerRunning = $false
|
||||
try {
|
||||
$dockerStatus = docker info 2>&1
|
||||
$dockerRunning = $LASTEXITCODE -eq 0
|
||||
} catch {
|
||||
$dockerRunning = $false
|
||||
}
|
||||
|
||||
if (-not $dockerRunning) {
|
||||
"[$timestamp] Error: Docker is not running. Backup failed." | Out-File -Append -FilePath $logFile
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check if Gitea container is running
|
||||
$containerRunning = docker ps --format "{{.Names}}" | Select-String -Pattern "gitea-db" -Quiet
|
||||
if (-not $containerRunning) {
|
||||
"[$timestamp] Error: Gitea database container is not running. Backup failed." | Out-File -Append -FilePath $logFile
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Create database dump
|
||||
"[$timestamp] Creating database backup to $backupFile..." | Out-File -Append -FilePath $logFile
|
||||
docker exec gitea-db pg_dump -U gitea -d gitea > $backupFile
|
||||
|
||||
# Check if backup was successful
|
||||
if ($LASTEXITCODE -eq 0 -and (Test-Path $backupFile) -and (Get-Item $backupFile).Length -gt 0) {
|
||||
"[$timestamp] Backup completed successfully!" | Out-File -Append -FilePath $logFile
|
||||
|
||||
# Optional: Compress the backup file
|
||||
$zipFileName = "$backupFile.zip"
|
||||
Compress-Archive -Path $backupFile -DestinationPath $zipFileName -Force
|
||||
Remove-Item $backupFile
|
||||
"[$timestamp] Backup compressed to $zipFileName" | Out-File -Append -FilePath $logFile
|
||||
|
||||
# Copy backup to redundant location
|
||||
if (Test-Path $redundantBackupDir) {
|
||||
try {
|
||||
$redundantBackupFile = Join-Path $redundantBackupDir (Split-Path -Leaf $zipFileName)
|
||||
Copy-Item -Path $zipFileName -Destination $redundantBackupFile -Force
|
||||
"[$timestamp] Backup copied to redundant location: $redundantBackupFile" | Out-File -Append -FilePath $logFile
|
||||
} catch {
|
||||
"[$timestamp] Error copying backup to redundant location: $_" | Out-File -Append -FilePath $logFile
|
||||
}
|
||||
} else {
|
||||
"[$timestamp] Warning: Redundant backup directory not found: $redundantBackupDir" | Out-File -Append -FilePath $logFile
|
||||
}
|
||||
} else {
|
||||
"[$timestamp] Backup failed!" | Out-File -Append -FilePath $logFile
|
||||
}
|
||||
|
||||
# Optional: Clean up old backups (keep last 10)
|
||||
$oldBackups = Get-ChildItem -Path $backupDir -Filter "gitea-db-backup-*.zip" | Sort-Object LastWriteTime -Descending | Select-Object -Skip 10
|
||||
foreach ($backup in $oldBackups) {
|
||||
Remove-Item $backup.FullName
|
||||
"[$timestamp] Removed old backup: $($backup.Name)" | Out-File -Append -FilePath $logFile
|
||||
# Gitea Database Backup Script
|
||||
$timestamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
|
||||
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$backupDir = Join-Path $scriptDir "backups"
|
||||
$backupFile = Join-Path $backupDir "gitea-db-backup-$timestamp.sql"
|
||||
$redundantBackupDir = "D:\Pr00jects\gitea-docker"
|
||||
|
||||
# Ensure backup directory exists
|
||||
if (-not (Test-Path $backupDir)) {
|
||||
New-Item -ItemType Directory -Path $backupDir
|
||||
}
|
||||
|
||||
# Ensure redundant backup directory exists
|
||||
if (-not (Test-Path $redundantBackupDir)) {
|
||||
try {
|
||||
New-Item -ItemType Directory -Path $redundantBackupDir -Force
|
||||
} catch {
|
||||
"[$timestamp] Warning: Could not create redundant backup directory at $redundantBackupDir. Error: $_" | Out-File -Append -FilePath $logFile
|
||||
}
|
||||
}
|
||||
|
||||
# Log execution of the script
|
||||
$logFile = Join-Path $backupDir "backup-log.txt"
|
||||
"[$timestamp] Starting database backup..." | Out-File -Append -FilePath $logFile
|
||||
|
||||
# Check if Docker is running
|
||||
$dockerRunning = $false
|
||||
try {
|
||||
$dockerStatus = docker info 2>&1
|
||||
$dockerRunning = $LASTEXITCODE -eq 0
|
||||
} catch {
|
||||
$dockerRunning = $false
|
||||
}
|
||||
|
||||
if (-not $dockerRunning) {
|
||||
"[$timestamp] Error: Docker is not running. Backup failed." | Out-File -Append -FilePath $logFile
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check if Gitea container is running
|
||||
$containerRunning = docker ps --format "{{.Names}}" | Select-String -Pattern "gitea-db" -Quiet
|
||||
if (-not $containerRunning) {
|
||||
"[$timestamp] Error: Gitea database container is not running. Backup failed." | Out-File -Append -FilePath $logFile
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Create database dump
|
||||
"[$timestamp] Creating database backup to $backupFile..." | Out-File -Append -FilePath $logFile
|
||||
docker exec gitea-db pg_dump -U gitea -d gitea > $backupFile
|
||||
|
||||
# Check if backup was successful
|
||||
if ($LASTEXITCODE -eq 0 -and (Test-Path $backupFile) -and (Get-Item $backupFile).Length -gt 0) {
|
||||
"[$timestamp] Backup completed successfully!" | Out-File -Append -FilePath $logFile
|
||||
|
||||
# Optional: Compress the backup file
|
||||
$zipFileName = "$backupFile.zip"
|
||||
Compress-Archive -Path $backupFile -DestinationPath $zipFileName -Force
|
||||
Remove-Item $backupFile
|
||||
"[$timestamp] Backup compressed to $zipFileName" | Out-File -Append -FilePath $logFile
|
||||
|
||||
# Copy backup to redundant location
|
||||
if (Test-Path $redundantBackupDir) {
|
||||
try {
|
||||
$redundantBackupFile = Join-Path $redundantBackupDir (Split-Path -Leaf $zipFileName)
|
||||
Copy-Item -Path $zipFileName -Destination $redundantBackupFile -Force
|
||||
"[$timestamp] Backup copied to redundant location: $redundantBackupFile" | Out-File -Append -FilePath $logFile
|
||||
} catch {
|
||||
"[$timestamp] Error copying backup to redundant location: $_" | Out-File -Append -FilePath $logFile
|
||||
}
|
||||
} else {
|
||||
"[$timestamp] Warning: Redundant backup directory not found: $redundantBackupDir" | Out-File -Append -FilePath $logFile
|
||||
}
|
||||
} else {
|
||||
"[$timestamp] Backup failed!" | Out-File -Append -FilePath $logFile
|
||||
}
|
||||
|
||||
# Optional: Clean up old backups (keep last 10)
|
||||
$oldBackups = Get-ChildItem -Path $backupDir -Filter "gitea-db-backup-*.zip" | Sort-Object LastWriteTime -Descending | Select-Object -Skip 10
|
||||
foreach ($backup in $oldBackups) {
|
||||
Remove-Item $backup.FullName
|
||||
"[$timestamp] Removed old backup: $($backup.Name)" | Out-File -Append -FilePath $logFile
|
||||
}
|
||||
@@ -1,88 +1,88 @@
|
||||
# Script to backup the entire Postgres Docker volume
|
||||
$timestamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
|
||||
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$backupDir = Join-Path $scriptDir "backups"
|
||||
$volumeName = "gitea-docker_postgres-data"
|
||||
$backupFile = "postgres-volume-backup-$timestamp.tar"
|
||||
$backupFilePath = Join-Path $backupDir $backupFile
|
||||
$redundantBackupDir = "D:\Pr00jects\gitea-docker"
|
||||
$logFile = Join-Path $backupDir "volume-backup-log.txt"
|
||||
$currentDir = Get-Location
|
||||
|
||||
# Ensure backup directory exists
|
||||
if (-not (Test-Path $backupDir)) {
|
||||
New-Item -ItemType Directory -Path $backupDir
|
||||
}
|
||||
|
||||
# Ensure redundant backup directory exists
|
||||
if (-not (Test-Path $redundantBackupDir)) {
|
||||
try {
|
||||
New-Item -ItemType Directory -Path $redundantBackupDir -Force
|
||||
} catch {
|
||||
Add-Content -Path $logFile -Value "[$timestamp] Warning: Could not create redundant backup directory at $redundantBackupDir. Error: $_"
|
||||
}
|
||||
}
|
||||
|
||||
# Log start of backup
|
||||
Add-Content -Path $logFile -Value "[$timestamp] Starting volume backup for $volumeName..."
|
||||
|
||||
# Check if volume exists
|
||||
$volumeExists = docker volume ls --format "{{.Name}}" | Select-String -Pattern "^$volumeName$"
|
||||
if (-not $volumeExists) {
|
||||
Write-Host "Volume $volumeName not found!" -ForegroundColor Red
|
||||
Add-Content -Path $logFile -Value "[$timestamp] Error: Volume $volumeName not found!"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Create a temporary container to access the volume
|
||||
Write-Host "Creating backup of Docker volume $volumeName..."
|
||||
Add-Content -Path $logFile -Value "[$timestamp] Creating backup to $backupFilePath..."
|
||||
|
||||
# Change to backup directory and use simple relative paths for Docker
|
||||
Set-Location -Path $backupDir
|
||||
docker run --rm -v ${volumeName}:/volume -v ${PWD}:/backup alpine tar -cf /backup/$backupFile -C /volume ./
|
||||
|
||||
# Restore original directory
|
||||
Set-Location -Path $currentDir
|
||||
|
||||
# Check if backup was successful
|
||||
if ($LASTEXITCODE -eq 0 -and (Test-Path $backupFilePath) -and (Get-Item $backupFilePath).Length -gt 0) {
|
||||
Write-Host "Volume backup completed successfully to $backupFilePath!" -ForegroundColor Green
|
||||
Add-Content -Path $logFile -Value "[$timestamp] Volume backup completed successfully!"
|
||||
|
||||
# Optional: Compress the backup file
|
||||
Write-Host "Compressing backup file..."
|
||||
Add-Content -Path $logFile -Value "[$timestamp] Compressing backup file..."
|
||||
$zipFileName = "$backupFilePath.zip"
|
||||
Compress-Archive -Path $backupFilePath -DestinationPath $zipFileName -Force
|
||||
Remove-Item $backupFilePath
|
||||
Write-Host "Backup compressed to $zipFileName" -ForegroundColor Green
|
||||
Add-Content -Path $logFile -Value "[$timestamp] Backup compressed to $zipFileName"
|
||||
|
||||
# Copy backup to redundant location
|
||||
if (Test-Path $redundantBackupDir) {
|
||||
try {
|
||||
$redundantBackupFile = Join-Path $redundantBackupDir (Split-Path -Leaf $zipFileName)
|
||||
Copy-Item -Path $zipFileName -Destination $redundantBackupFile -Force
|
||||
Write-Host "Backup copied to redundant location: $redundantBackupFile" -ForegroundColor Green
|
||||
Add-Content -Path $logFile -Value "[$timestamp] Backup copied to redundant location: $redundantBackupFile"
|
||||
} catch {
|
||||
Write-Host "Error copying backup to redundant location: $_" -ForegroundColor Red
|
||||
Add-Content -Path $logFile -Value "[$timestamp] Error copying backup to redundant location: $_"
|
||||
}
|
||||
} else {
|
||||
Write-Host "Warning: Redundant backup directory not found: $redundantBackupDir" -ForegroundColor Yellow
|
||||
Add-Content -Path $logFile -Value "[$timestamp] Warning: Redundant backup directory not found: $redundantBackupDir"
|
||||
}
|
||||
} else {
|
||||
Write-Host "Volume backup failed!" -ForegroundColor Red
|
||||
Add-Content -Path $logFile -Value "[$timestamp] Volume backup failed!"
|
||||
}
|
||||
|
||||
# Optional: Clean up old volume backups (keep last 5)
|
||||
$oldBackups = Get-ChildItem -Path $backupDir -Filter "postgres-volume-backup-*.zip" | Sort-Object LastWriteTime -Descending | Select-Object -Skip 5
|
||||
foreach ($backup in $oldBackups) {
|
||||
Remove-Item $backup.FullName
|
||||
Write-Host "Removed old volume backup: $($backup.Name)"
|
||||
Add-Content -Path $logFile -Value "[$timestamp] Removed old volume backup: $($backup.Name)"
|
||||
# Script to backup the entire Postgres Docker volume
|
||||
$timestamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
|
||||
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$backupDir = Join-Path $scriptDir "backups"
|
||||
$volumeName = "gitea-docker_postgres-data"
|
||||
$backupFile = "postgres-volume-backup-$timestamp.tar"
|
||||
$backupFilePath = Join-Path $backupDir $backupFile
|
||||
$redundantBackupDir = "D:\Pr00jects\gitea-docker"
|
||||
$logFile = Join-Path $backupDir "volume-backup-log.txt"
|
||||
$currentDir = Get-Location
|
||||
|
||||
# Ensure backup directory exists
|
||||
if (-not (Test-Path $backupDir)) {
|
||||
New-Item -ItemType Directory -Path $backupDir
|
||||
}
|
||||
|
||||
# Ensure redundant backup directory exists
|
||||
if (-not (Test-Path $redundantBackupDir)) {
|
||||
try {
|
||||
New-Item -ItemType Directory -Path $redundantBackupDir -Force
|
||||
} catch {
|
||||
Add-Content -Path $logFile -Value "[$timestamp] Warning: Could not create redundant backup directory at $redundantBackupDir. Error: $_"
|
||||
}
|
||||
}
|
||||
|
||||
# Log start of backup
|
||||
Add-Content -Path $logFile -Value "[$timestamp] Starting volume backup for $volumeName..."
|
||||
|
||||
# Check if volume exists
|
||||
$volumeExists = docker volume ls --format "{{.Name}}" | Select-String -Pattern "^$volumeName$"
|
||||
if (-not $volumeExists) {
|
||||
Write-Host "Volume $volumeName not found!" -ForegroundColor Red
|
||||
Add-Content -Path $logFile -Value "[$timestamp] Error: Volume $volumeName not found!"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Create a temporary container to access the volume
|
||||
Write-Host "Creating backup of Docker volume $volumeName..."
|
||||
Add-Content -Path $logFile -Value "[$timestamp] Creating backup to $backupFilePath..."
|
||||
|
||||
# Change to backup directory and use simple relative paths for Docker
|
||||
Set-Location -Path $backupDir
|
||||
docker run --rm -v ${volumeName}:/volume -v ${PWD}:/backup alpine tar -cf /backup/$backupFile -C /volume ./
|
||||
|
||||
# Restore original directory
|
||||
Set-Location -Path $currentDir
|
||||
|
||||
# Check if backup was successful
|
||||
if ($LASTEXITCODE -eq 0 -and (Test-Path $backupFilePath) -and (Get-Item $backupFilePath).Length -gt 0) {
|
||||
Write-Host "Volume backup completed successfully to $backupFilePath!" -ForegroundColor Green
|
||||
Add-Content -Path $logFile -Value "[$timestamp] Volume backup completed successfully!"
|
||||
|
||||
# Optional: Compress the backup file
|
||||
Write-Host "Compressing backup file..."
|
||||
Add-Content -Path $logFile -Value "[$timestamp] Compressing backup file..."
|
||||
$zipFileName = "$backupFilePath.zip"
|
||||
Compress-Archive -Path $backupFilePath -DestinationPath $zipFileName -Force
|
||||
Remove-Item $backupFilePath
|
||||
Write-Host "Backup compressed to $zipFileName" -ForegroundColor Green
|
||||
Add-Content -Path $logFile -Value "[$timestamp] Backup compressed to $zipFileName"
|
||||
|
||||
# Copy backup to redundant location
|
||||
if (Test-Path $redundantBackupDir) {
|
||||
try {
|
||||
$redundantBackupFile = Join-Path $redundantBackupDir (Split-Path -Leaf $zipFileName)
|
||||
Copy-Item -Path $zipFileName -Destination $redundantBackupFile -Force
|
||||
Write-Host "Backup copied to redundant location: $redundantBackupFile" -ForegroundColor Green
|
||||
Add-Content -Path $logFile -Value "[$timestamp] Backup copied to redundant location: $redundantBackupFile"
|
||||
} catch {
|
||||
Write-Host "Error copying backup to redundant location: $_" -ForegroundColor Red
|
||||
Add-Content -Path $logFile -Value "[$timestamp] Error copying backup to redundant location: $_"
|
||||
}
|
||||
} else {
|
||||
Write-Host "Warning: Redundant backup directory not found: $redundantBackupDir" -ForegroundColor Yellow
|
||||
Add-Content -Path $logFile -Value "[$timestamp] Warning: Redundant backup directory not found: $redundantBackupDir"
|
||||
}
|
||||
} else {
|
||||
Write-Host "Volume backup failed!" -ForegroundColor Red
|
||||
Add-Content -Path $logFile -Value "[$timestamp] Volume backup failed!"
|
||||
}
|
||||
|
||||
# Optional: Clean up old volume backups (keep last 5)
|
||||
$oldBackups = Get-ChildItem -Path $backupDir -Filter "postgres-volume-backup-*.zip" | Sort-Object LastWriteTime -Descending | Select-Object -Skip 5
|
||||
foreach ($backup in $oldBackups) {
|
||||
Remove-Item $backup.FullName
|
||||
Write-Host "Removed old volume backup: $($backup.Name)"
|
||||
Add-Content -Path $logFile -Value "[$timestamp] Removed old volume backup: $($backup.Name)"
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
backups/gitea-db-backup-2025-04-21_03-03-47.sql.zip
Normal file
BIN
backups/gitea-db-backup-2025-04-21_03-03-47.sql.zip
Normal file
Binary file not shown.
BIN
backups/gitea-db-backup-2025-04-22_03-07-16.sql.zip
Normal file
BIN
backups/gitea-db-backup-2025-04-22_03-07-16.sql.zip
Normal file
Binary file not shown.
BIN
backups/gitea-db-backup-2025-04-23_03-00-49.sql.zip
Normal file
BIN
backups/gitea-db-backup-2025-04-23_03-00-49.sql.zip
Normal file
Binary file not shown.
BIN
backups/gitea-db-backup-2025-04-25_19-01-37.sql
Normal file
BIN
backups/gitea-db-backup-2025-04-25_19-01-37.sql
Normal file
Binary file not shown.
BIN
backups/gitea-db-backup-2025-05-18_01-16-38.sql.zip
Normal file
BIN
backups/gitea-db-backup-2025-05-18_01-16-38.sql.zip
Normal file
Binary file not shown.
BIN
backups/gitea-db-backup-2025-05-18_03-00-05.sql.zip
Normal file
BIN
backups/gitea-db-backup-2025-05-18_03-00-05.sql.zip
Normal file
Binary file not shown.
BIN
backups/gitea-db-backup-2025-05-19_03-00-05.sql.zip
Normal file
BIN
backups/gitea-db-backup-2025-05-19_03-00-05.sql.zip
Normal file
Binary file not shown.
BIN
backups/gitea-db-backup-2025-05-20_03-00-53.sql.zip
Normal file
BIN
backups/gitea-db-backup-2025-05-20_03-00-53.sql.zip
Normal file
Binary file not shown.
BIN
backups/gitea-db-backup-2025-05-21_03-03-22.sql.zip
Normal file
BIN
backups/gitea-db-backup-2025-05-21_03-03-22.sql.zip
Normal file
Binary file not shown.
BIN
backups/gitea-db-backup-2025-05-22_03-03-36.sql.zip
Normal file
BIN
backups/gitea-db-backup-2025-05-22_03-03-36.sql.zip
Normal file
Binary file not shown.
BIN
backups/gitea-db-backup-2025-05-23_03-21-26.sql
Normal file
BIN
backups/gitea-db-backup-2025-05-23_03-21-26.sql
Normal file
Binary file not shown.
BIN
backups/gitea-db-backup-2025-05-28_02-42-28.sql
Normal file
BIN
backups/gitea-db-backup-2025-05-28_02-42-28.sql
Normal file
Binary file not shown.
BIN
backups/gitea-db-backup-2025-06-09_21-22-55.sql.zip
Normal file
BIN
backups/gitea-db-backup-2025-06-09_21-22-55.sql.zip
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
backups/postgres-volume-backup-2025-05-22_03-03-49.tar.zip
Normal file
BIN
backups/postgres-volume-backup-2025-05-22_03-03-49.tar.zip
Normal file
Binary file not shown.
BIN
backups/postgres-volume-backup-2025-05-23_08-01-05.tar
Normal file
BIN
backups/postgres-volume-backup-2025-05-23_08-01-05.tar
Normal file
Binary file not shown.
BIN
backups/postgres-volume-backup-2025-06-09_21-30-15.tar.zip
Normal file
BIN
backups/postgres-volume-backup-2025-06-09_21-30-15.tar.zip
Normal file
Binary file not shown.
BIN
backups/postgres-volume-backup.tar
Normal file
BIN
backups/postgres-volume-backup.tar
Normal file
Binary file not shown.
@@ -1,24 +1,104 @@
|
||||
[2025-04-19_19-40-51] Starting volume backup for gitea-docker_postgres-data...
|
||||
[2025-04-19_19-40-51] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-19_19-40-51.tar...
|
||||
[2025-04-19_19-40-51] Volume backup failed!
|
||||
[2025-04-19_19-41-05] Starting volume backup for gitea-docker_postgres-data...
|
||||
[2025-04-19_19-41-05] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-19_19-41-05.tar...
|
||||
[2025-04-19_19-41-05] Volume backup failed!
|
||||
[2025-04-19_19-42-55] Starting volume backup for gitea-docker_postgres-data...
|
||||
[2025-04-19_19-42-55] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-19_19-42-55.tar...
|
||||
[2025-04-19_19-42-55] Volume backup completed successfully!
|
||||
[2025-04-19_19-42-55] Compressing backup file...
|
||||
[2025-04-19_19-42-55] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-19_19-42-55.tar.zip
|
||||
[2025-04-19_19-42-55] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-04-19_19-42-55.tar.zip
|
||||
[2025-04-19_19-43-53] Starting volume backup for gitea-docker_postgres-data...
|
||||
[2025-04-19_19-43-53] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-19_19-43-53.tar...
|
||||
[2025-04-19_19-43-53] Volume backup completed successfully!
|
||||
[2025-04-19_19-43-53] Compressing backup file...
|
||||
[2025-04-19_19-43-53] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-19_19-43-53.tar.zip
|
||||
[2025-04-19_19-43-53] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-04-19_19-43-53.tar.zip
|
||||
[2025-04-19_19-44-40] Starting volume backup for gitea-docker_postgres-data...
|
||||
[2025-04-19_19-44-40] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-19_19-44-40.tar...
|
||||
[2025-04-19_19-44-40] Volume backup completed successfully!
|
||||
[2025-04-19_19-44-40] Compressing backup file...
|
||||
[2025-04-19_19-44-40] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-19_19-44-40.tar.zip
|
||||
[2025-04-19_19-44-40] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-04-19_19-44-40.tar.zip
|
||||
[2025-04-19_19-40-51] Starting volume backup for gitea-docker_postgres-data...
|
||||
[2025-04-19_19-40-51] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-19_19-40-51.tar...
|
||||
[2025-04-19_19-40-51] Volume backup failed!
|
||||
[2025-04-19_19-41-05] Starting volume backup for gitea-docker_postgres-data...
|
||||
[2025-04-19_19-41-05] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-19_19-41-05.tar...
|
||||
[2025-04-19_19-41-05] Volume backup failed!
|
||||
[2025-04-19_19-42-55] Starting volume backup for gitea-docker_postgres-data...
|
||||
[2025-04-19_19-42-55] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-19_19-42-55.tar...
|
||||
[2025-04-19_19-42-55] Volume backup completed successfully!
|
||||
[2025-04-19_19-42-55] Compressing backup file...
|
||||
[2025-04-19_19-42-55] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-19_19-42-55.tar.zip
|
||||
[2025-04-19_19-42-55] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-04-19_19-42-55.tar.zip
|
||||
[2025-04-19_19-43-53] Starting volume backup for gitea-docker_postgres-data...
|
||||
[2025-04-19_19-43-53] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-19_19-43-53.tar...
|
||||
[2025-04-19_19-43-53] Volume backup completed successfully!
|
||||
[2025-04-19_19-43-53] Compressing backup file...
|
||||
[2025-04-19_19-43-53] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-19_19-43-53.tar.zip
|
||||
[2025-04-19_19-43-53] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-04-19_19-43-53.tar.zip
|
||||
[2025-04-19_19-44-40] Starting volume backup for gitea-docker_postgres-data...
|
||||
[2025-04-19_19-44-40] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-19_19-44-40.tar...
|
||||
[2025-04-19_19-44-40] Volume backup completed successfully!
|
||||
[2025-04-19_19-44-40] Compressing backup file...
|
||||
[2025-04-19_19-44-40] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-19_19-44-40.tar.zip
|
||||
[2025-04-19_19-44-40] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-04-19_19-44-40.tar.zip
|
||||
[2025-04-20_03-06-24] Starting volume backup for gitea-docker_postgres-data...
|
||||
[2025-04-20_03-06-24] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-20_03-06-24.tar...
|
||||
[2025-04-20_03-06-24] Volume backup completed successfully!
|
||||
[2025-04-20_03-06-24] Compressing backup file...
|
||||
[2025-04-20_03-06-24] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-20_03-06-24.tar.zip
|
||||
[2025-04-20_03-06-24] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-04-20_03-06-24.tar.zip
|
||||
[2025-04-21_03-05-47] Starting volume backup for gitea-docker_postgres-data...
|
||||
[2025-04-21_03-05-47] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-21_03-05-47.tar...
|
||||
[2025-04-21_03-05-47] Volume backup completed successfully!
|
||||
[2025-04-21_03-05-47] Compressing backup file...
|
||||
[2025-04-21_03-05-47] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-21_03-05-47.tar.zip
|
||||
[2025-04-21_03-05-47] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-04-21_03-05-47.tar.zip
|
||||
[2025-04-21_03-05-47] Removed old volume backup: postgres-volume-backup-2025-03-01_23-23-13.tar.zip
|
||||
[2025-04-22_03-27-19] Starting volume backup for gitea-docker_postgres-data...
|
||||
[2025-04-22_03-27-19] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-22_03-27-19.tar...
|
||||
[2025-04-22_03-27-19] Volume backup completed successfully!
|
||||
[2025-04-22_03-27-19] Compressing backup file...
|
||||
[2025-04-22_03-27-19] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-22_03-27-19.tar.zip
|
||||
[2025-04-22_03-27-19] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-04-22_03-27-19.tar.zip
|
||||
[2025-04-22_03-27-19] Removed old volume backup: postgres-volume-backup-2025-04-19_19-42-55.tar.zip
|
||||
[2025-04-23_08-10-53] Starting volume backup for gitea-docker_postgres-data...
|
||||
[2025-04-23_08-10-53] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-23_08-10-53.tar...
|
||||
[2025-04-23_08-10-53] Volume backup completed successfully!
|
||||
[2025-04-23_08-10-53] Compressing backup file...
|
||||
[2025-04-23_08-10-53] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-04-23_08-10-53.tar.zip
|
||||
[2025-04-23_08-10-53] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-04-23_08-10-53.tar.zip
|
||||
[2025-04-23_08-10-53] Removed old volume backup: postgres-volume-backup-2025-04-19_19-43-53.tar.zip
|
||||
[2025-05-18_01-22-29] Starting volume backup for gitea-docker_postgres-data...
|
||||
[2025-05-18_01-22-29] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-05-18_01-22-29.tar...
|
||||
[2025-05-18_01-22-29] Volume backup completed successfully!
|
||||
[2025-05-18_01-22-29] Compressing backup file...
|
||||
[2025-05-18_01-22-29] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-05-18_01-22-29.tar.zip
|
||||
[2025-05-18_01-22-29] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-05-18_01-22-29.tar.zip
|
||||
[2025-05-18_01-22-29] Removed old volume backup: postgres-volume-backup-2025-04-19_19-44-40.tar.zip
|
||||
[2025-05-18_03-00-14] Starting volume backup for gitea-docker_postgres-data...
|
||||
[2025-05-18_03-00-14] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-05-18_03-00-14.tar...
|
||||
[2025-05-18_03-00-14] Volume backup completed successfully!
|
||||
[2025-05-18_03-00-14] Compressing backup file...
|
||||
[2025-05-18_03-00-14] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-05-18_03-00-14.tar.zip
|
||||
[2025-05-18_03-00-14] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-05-18_03-00-14.tar.zip
|
||||
[2025-05-18_03-00-14] Removed old volume backup: postgres-volume-backup-2025-04-20_03-06-24.tar.zip
|
||||
[2025-05-19_03-00-14] Starting volume backup for gitea-docker_postgres-data...
|
||||
[2025-05-19_03-00-14] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-05-19_03-00-14.tar...
|
||||
[2025-05-19_03-00-14] Volume backup completed successfully!
|
||||
[2025-05-19_03-00-14] Compressing backup file...
|
||||
[2025-05-19_03-00-14] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-05-19_03-00-14.tar.zip
|
||||
[2025-05-19_03-00-14] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-05-19_03-00-14.tar.zip
|
||||
[2025-05-19_03-00-14] Removed old volume backup: postgres-volume-backup-2025-04-21_03-05-47.tar.zip
|
||||
[2025-05-20_03-14-23] Starting volume backup for gitea-docker_postgres-data...
|
||||
[2025-05-20_03-14-23] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-05-20_03-14-23.tar...
|
||||
[2025-05-20_03-14-23] Volume backup completed successfully!
|
||||
[2025-05-20_03-14-23] Compressing backup file...
|
||||
[2025-05-20_03-14-23] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-05-20_03-14-23.tar.zip
|
||||
[2025-05-20_03-14-23] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-05-20_03-14-23.tar.zip
|
||||
[2025-05-20_03-14-23] Removed old volume backup: postgres-volume-backup-2025-04-22_03-27-19.tar.zip
|
||||
[2025-05-21_03-08-24] Starting volume backup for gitea-docker_postgres-data...
|
||||
[2025-05-21_03-08-24] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-05-21_03-08-24.tar...
|
||||
[2025-05-21_03-08-24] Volume backup completed successfully!
|
||||
[2025-05-21_03-08-24] Compressing backup file...
|
||||
[2025-05-21_03-08-24] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-05-21_03-08-24.tar.zip
|
||||
[2025-05-21_03-08-24] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-05-21_03-08-24.tar.zip
|
||||
[2025-05-21_03-08-24] Removed old volume backup: postgres-volume-backup-2025-04-23_08-10-53.tar.zip
|
||||
[2025-05-22_03-03-49] Starting volume backup for gitea-docker_postgres-data...
|
||||
[2025-05-22_03-03-49] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-05-22_03-03-49.tar...
|
||||
[2025-05-22_03-03-49] Volume backup completed successfully!
|
||||
[2025-05-22_03-03-49] Compressing backup file...
|
||||
[2025-05-22_03-03-49] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-05-22_03-03-49.tar.zip
|
||||
[2025-05-22_03-03-49] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-05-22_03-03-49.tar.zip
|
||||
[2025-05-22_03-03-49] Removed old volume backup: postgres-volume-backup-2025-05-18_01-22-29.tar.zip
|
||||
[2025-05-23_08-01-05] Starting volume backup for gitea-docker_postgres-data...
|
||||
[2025-05-23_08-01-05] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-05-23_08-01-05.tar...
|
||||
[2025-05-23_08-01-05] Volume backup completed successfully!
|
||||
[2025-05-23_08-01-05] Compressing backup file...
|
||||
[2025-06-09_21-30-15] Starting volume backup for gitea-docker_postgres-data...
|
||||
[2025-06-09_21-30-15] Creating backup to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-06-09_21-30-15.tar...
|
||||
[2025-06-09_21-30-15] Volume backup completed successfully!
|
||||
[2025-06-09_21-30-15] Compressing backup file...
|
||||
[2025-06-09_21-30-15] Backup compressed to C:\Users\benne\Projects\gitea-docker\backups\postgres-volume-backup-2025-06-09_21-30-15.tar.zip
|
||||
[2025-06-09_21-30-15] Backup copied to redundant location: D:\Pr00jects\gitea-docker\postgres-volume-backup-2025-06-09_21-30-15.tar.zip
|
||||
[2025-06-09_21-30-15] Removed old volume backup: postgres-volume-backup-2025-05-18_03-00-14.tar.zip
|
||||
|
||||
20
docker-compose.headscale.yml
Normal file
20
docker-compose.headscale.yml
Normal file
@@ -0,0 +1,20 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
headscale:
|
||||
image: headscale/headscale:latest
|
||||
container_name: headscale
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8081:8080" # Web UI and API (avoiding conflict with Traefik)
|
||||
- "50443:50443" # gRPC
|
||||
volumes:
|
||||
- ./headscale/config:/etc/headscale
|
||||
- ./headscale/data:/var/lib/headscale
|
||||
command: serve
|
||||
networks:
|
||||
- headscale-net
|
||||
|
||||
networks:
|
||||
headscale-net:
|
||||
driver: bridge
|
||||
@@ -3,6 +3,10 @@ version: "3"
|
||||
networks:
|
||||
gitea:
|
||||
external: false
|
||||
traefik:
|
||||
external: true
|
||||
immich_default:
|
||||
external: true
|
||||
|
||||
volumes:
|
||||
gitea-data:
|
||||
@@ -15,18 +19,20 @@ services:
|
||||
container_name: traefik
|
||||
restart: always
|
||||
ports:
|
||||
- "80:80" # HTTP
|
||||
- "443:443" # HTTPS
|
||||
- "8080:8080" # Dashboard
|
||||
- "8080:80" # HTTP (changed from 80 to 8080 for ISP testing)
|
||||
- "8443:443" # HTTPS (changed from 443 to 8443 for ISP testing)
|
||||
- "8081:8080" # Dashboard (changed to avoid conflict)
|
||||
|
||||
networks:
|
||||
- gitea
|
||||
- traefik
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
- traefik-certs:/letsencrypt
|
||||
command:
|
||||
- "--providers.docker=true"
|
||||
- "--providers.docker.exposedbydefault=false"
|
||||
- "--providers.docker.network=gitea-docker_gitea"
|
||||
- "--providers.docker.network=traefik"
|
||||
- "--entrypoints.web.address=:80"
|
||||
- "--entrypoints.websecure.address=:443"
|
||||
- "--entrypoints.web.http.redirections.entryPoint.to=websecure"
|
||||
@@ -53,7 +59,7 @@ services:
|
||||
- GITEA__database__PASSWD=gitea
|
||||
# Server Configuration
|
||||
- GITEA__server__DOMAIN=bee8333.ddns.net
|
||||
- GITEA__server__ROOT_URL=https://bee8333.ddns.net/
|
||||
- GITEA__server__ROOT_URL=https://bee8333.ddns.net/gitea/
|
||||
- GITEA__server__PROTOCOL=http
|
||||
- GITEA__server__HTTP_PORT=3000
|
||||
- GITEA__server__SSH_DOMAIN=bee8333.ddns.net
|
||||
@@ -68,30 +74,63 @@ services:
|
||||
restart: always
|
||||
networks:
|
||||
- gitea
|
||||
- traefik
|
||||
volumes:
|
||||
- gitea-data:/data
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
# - /etc/timezone:/etc/timezone:ro
|
||||
# - /etc/localtime:/etc/localtime:ro
|
||||
ports:
|
||||
- "2224:22" # SSH: Host port 2224 -> Container port 22
|
||||
depends_on:
|
||||
- db
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
# HTTP Configuration for HTTPS access
|
||||
- "traefik.http.routers.gitea.rule=Host(`bee8333.ddns.net`)"
|
||||
- "traefik.docker.network=traefik"
|
||||
# HTTPS Configuration for /gitea subpath
|
||||
- "traefik.http.routers.gitea.rule=Host(`bee8333.ddns.net`) && PathPrefix(`/gitea`)"
|
||||
- "traefik.http.routers.gitea.entrypoints=websecure"
|
||||
- "traefik.http.routers.gitea.tls.certresolver=letsencrypt"
|
||||
- "traefik.http.routers.gitea.priority=10"
|
||||
- "traefik.http.services.gitea.loadbalancer.server.port=3000"
|
||||
- "traefik.http.middlewares.gitea-stripprefix.stripprefix.prefixes=/gitea"
|
||||
- "traefik.http.middlewares.gitea-headers.headers.customrequestheaders.X-Forwarded-Proto=https"
|
||||
- "traefik.http.routers.gitea.middlewares=gitea-headers@docker"
|
||||
- "traefik.http.routers.gitea.middlewares=gitea-stripprefix@docker,gitea-headers@docker"
|
||||
# HTTP Configuration for HTTP -> HTTPS redirection
|
||||
- "traefik.http.routers.gitea-http.rule=Host(`bee8333.ddns.net`)"
|
||||
- "traefik.http.routers.gitea-http.rule=Host(`bee8333.ddns.net`) && PathPrefix(`/gitea`)"
|
||||
- "traefik.http.routers.gitea-http.entrypoints=web"
|
||||
- "traefik.http.middlewares.https-redirect.redirectscheme.scheme=https"
|
||||
- "traefik.http.middlewares.https-redirect.redirectscheme.permanent=true"
|
||||
- "traefik.http.routers.gitea-http.middlewares=https-redirect@docker"
|
||||
|
||||
headscale:
|
||||
image: headscale/headscale:latest
|
||||
container_name: headscale
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "3478:3478/udp" # STUN for DERP relay
|
||||
volumes:
|
||||
- ./headscale/config:/etc/headscale
|
||||
- ./headscale/data:/var/lib/headscale
|
||||
command: serve
|
||||
networks:
|
||||
- gitea
|
||||
- traefik
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.docker.network=traefik"
|
||||
# HTTPS Configuration for /headscale subpath
|
||||
- "traefik.http.routers.headscale.rule=Host(`bee8333.ddns.net`) && PathPrefix(`/headscale`)"
|
||||
- "traefik.http.routers.headscale.entrypoints=websecure"
|
||||
- "traefik.http.routers.headscale.tls.certresolver=letsencrypt"
|
||||
- "traefik.http.services.headscale.loadbalancer.server.port=8080"
|
||||
- "traefik.http.middlewares.headscale-stripprefix.stripprefix.prefixes=/headscale"
|
||||
- "traefik.http.middlewares.headscale-headers.headers.customrequestheaders.X-Forwarded-Proto=https"
|
||||
- "traefik.http.routers.headscale.middlewares=headscale-stripprefix@docker,headscale-headers@docker"
|
||||
# HTTP Configuration for HTTP -> HTTPS redirection
|
||||
- "traefik.http.routers.headscale-http.rule=Host(`bee8333.ddns.net`) && PathPrefix(`/headscale`)"
|
||||
- "traefik.http.routers.headscale-http.entrypoints=web"
|
||||
- "traefik.http.routers.headscale-http.middlewares=https-redirect@docker"
|
||||
|
||||
db:
|
||||
image: postgres:14
|
||||
container_name: gitea-db
|
||||
|
||||
@@ -1,83 +1,83 @@
|
||||
# Script to ensure Docker is running before scheduled backup
|
||||
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$logFile = Join-Path $scriptDir "backups\docker-status.log"
|
||||
$timestamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
|
||||
|
||||
# Ensure log directory exists
|
||||
$backupDir = Join-Path $scriptDir "backups"
|
||||
if (-not (Test-Path $backupDir)) {
|
||||
New-Item -ItemType Directory -Path $backupDir
|
||||
}
|
||||
|
||||
"[$timestamp] Checking Docker status..." | Out-File -Append -FilePath $logFile
|
||||
|
||||
# Check if Docker Desktop is running
|
||||
$dockerProcess = Get-Process "Docker Desktop" -ErrorAction SilentlyContinue
|
||||
if ($null -eq $dockerProcess) {
|
||||
"[$timestamp] Docker Desktop is not running. Attempting to start..." | Out-File -Append -FilePath $logFile
|
||||
|
||||
# Path to Docker Desktop
|
||||
$dockerPath = "C:\Program Files\Docker\Docker\Docker Desktop.exe"
|
||||
if (Test-Path $dockerPath) {
|
||||
Start-Process $dockerPath
|
||||
"[$timestamp] Started Docker Desktop." | Out-File -Append -FilePath $logFile
|
||||
|
||||
# Wait for Docker to start up (give it 60 seconds)
|
||||
$maxWaitTime = 60
|
||||
$waitTime = 0
|
||||
$dockerRunning = $false
|
||||
|
||||
while (-not $dockerRunning -and $waitTime -lt $maxWaitTime) {
|
||||
Start-Sleep -Seconds 5
|
||||
$waitTime += 5
|
||||
|
||||
try {
|
||||
$dockerStatus = docker info 2>&1
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
$dockerRunning = $true
|
||||
"[$timestamp] Docker is now running after waiting $waitTime seconds." | Out-File -Append -FilePath $logFile
|
||||
}
|
||||
} catch {
|
||||
# Keep waiting
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $dockerRunning) {
|
||||
"[$timestamp] Docker did not start successfully after waiting $maxWaitTime seconds." | Out-File -Append -FilePath $logFile
|
||||
}
|
||||
} else {
|
||||
"[$timestamp] Docker Desktop executable not found at expected location: $dockerPath" | Out-File -Append -FilePath $logFile
|
||||
}
|
||||
} else {
|
||||
"[$timestamp] Docker Desktop is already running." | Out-File -Append -FilePath $logFile
|
||||
}
|
||||
|
||||
# Check if containers are running
|
||||
try {
|
||||
$containersRunning = docker ps 2>&1
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
"[$timestamp] Docker containers status: " | Out-File -Append -FilePath $logFile
|
||||
$runningContainers = docker ps --format "{{.Names}}" 2>&1
|
||||
$runningContainers | Out-File -Append -FilePath $logFile
|
||||
|
||||
# Check specifically for gitea containers
|
||||
$giteaRunning = $runningContainers | Select-String -Pattern "gitea" -Quiet
|
||||
if (-not $giteaRunning) {
|
||||
"[$timestamp] Gitea containers are not running. Starting containers..." | Out-File -Append -FilePath $logFile
|
||||
|
||||
# Navigate to gitea-docker directory and start containers
|
||||
Set-Location $scriptDir
|
||||
docker-compose up -d 2>&1 | Out-File -Append -FilePath $logFile
|
||||
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
"[$timestamp] Successfully started Gitea containers." | Out-File -Append -FilePath $logFile
|
||||
} else {
|
||||
"[$timestamp] Failed to start Gitea containers." | Out-File -Append -FilePath $logFile
|
||||
}
|
||||
}
|
||||
} else {
|
||||
"[$timestamp] Failed to check running containers. Docker might not be ready yet." | Out-File -Append -FilePath $logFile
|
||||
}
|
||||
} catch {
|
||||
"[$timestamp] Error checking Docker containers: $_" | Out-File -Append -FilePath $logFile
|
||||
# Script to ensure Docker is running before scheduled backup
|
||||
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$logFile = Join-Path $scriptDir "backups\docker-status.log"
|
||||
$timestamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
|
||||
|
||||
# Ensure log directory exists
|
||||
$backupDir = Join-Path $scriptDir "backups"
|
||||
if (-not (Test-Path $backupDir)) {
|
||||
New-Item -ItemType Directory -Path $backupDir
|
||||
}
|
||||
|
||||
"[$timestamp] Checking Docker status..." | Out-File -Append -FilePath $logFile
|
||||
|
||||
# Check if Docker Desktop is running
|
||||
$dockerProcess = Get-Process "Docker Desktop" -ErrorAction SilentlyContinue
|
||||
if ($null -eq $dockerProcess) {
|
||||
"[$timestamp] Docker Desktop is not running. Attempting to start..." | Out-File -Append -FilePath $logFile
|
||||
|
||||
# Path to Docker Desktop
|
||||
$dockerPath = "C:\Program Files\Docker\Docker\Docker Desktop.exe"
|
||||
if (Test-Path $dockerPath) {
|
||||
Start-Process $dockerPath
|
||||
"[$timestamp] Started Docker Desktop." | Out-File -Append -FilePath $logFile
|
||||
|
||||
# Wait for Docker to start up (give it 60 seconds)
|
||||
$maxWaitTime = 60
|
||||
$waitTime = 0
|
||||
$dockerRunning = $false
|
||||
|
||||
while (-not $dockerRunning -and $waitTime -lt $maxWaitTime) {
|
||||
Start-Sleep -Seconds 5
|
||||
$waitTime += 5
|
||||
|
||||
try {
|
||||
$dockerStatus = docker info 2>&1
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
$dockerRunning = $true
|
||||
"[$timestamp] Docker is now running after waiting $waitTime seconds." | Out-File -Append -FilePath $logFile
|
||||
}
|
||||
} catch {
|
||||
# Keep waiting
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $dockerRunning) {
|
||||
"[$timestamp] Docker did not start successfully after waiting $maxWaitTime seconds." | Out-File -Append -FilePath $logFile
|
||||
}
|
||||
} else {
|
||||
"[$timestamp] Docker Desktop executable not found at expected location: $dockerPath" | Out-File -Append -FilePath $logFile
|
||||
}
|
||||
} else {
|
||||
"[$timestamp] Docker Desktop is already running." | Out-File -Append -FilePath $logFile
|
||||
}
|
||||
|
||||
# Check if containers are running
|
||||
try {
|
||||
$containersRunning = docker ps 2>&1
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
"[$timestamp] Docker containers status: " | Out-File -Append -FilePath $logFile
|
||||
$runningContainers = docker ps --format "{{.Names}}" 2>&1
|
||||
$runningContainers | Out-File -Append -FilePath $logFile
|
||||
|
||||
# Check specifically for gitea containers
|
||||
$giteaRunning = $runningContainers | Select-String -Pattern "gitea" -Quiet
|
||||
if (-not $giteaRunning) {
|
||||
"[$timestamp] Gitea containers are not running. Starting containers..." | Out-File -Append -FilePath $logFile
|
||||
|
||||
# Navigate to gitea-docker directory and start containers
|
||||
Set-Location $scriptDir
|
||||
docker-compose up -d 2>&1 | Out-File -Append -FilePath $logFile
|
||||
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
"[$timestamp] Successfully started Gitea containers." | Out-File -Append -FilePath $logFile
|
||||
} else {
|
||||
"[$timestamp] Failed to start Gitea containers." | Out-File -Append -FilePath $logFile
|
||||
}
|
||||
}
|
||||
} else {
|
||||
"[$timestamp] Failed to check running containers. Docker might not be ready yet." | Out-File -Append -FilePath $logFile
|
||||
}
|
||||
} catch {
|
||||
"[$timestamp] Error checking Docker containers: $_" | Out-File -Append -FilePath $logFile
|
||||
}
|
||||
BIN
gitea-dump.zip
Normal file
BIN
gitea-dump.zip
Normal file
Binary file not shown.
@@ -1,37 +1,37 @@
|
||||
APP_NAME = BeeBrain
|
||||
RUN_MODE = prod
|
||||
RUN_USER = git
|
||||
|
||||
[server]
|
||||
DOMAIN = bee8333.ddns.net
|
||||
SSH_DOMAIN = bee8333.ddns.net
|
||||
HTTP_PORT = 3000
|
||||
ROOT_URL = https://bee8333.ddns.net/
|
||||
DISABLE_SSH = false
|
||||
SSH_PORT = 222
|
||||
SSH_LISTEN_PORT = 22
|
||||
LFS_START_SERVER = true
|
||||
PROTOCOL = https
|
||||
CERT_FILE = /data/gitea/cert.pem
|
||||
KEY_FILE = /data/gitea/key.pem
|
||||
|
||||
[database]
|
||||
DB_TYPE = postgres
|
||||
HOST = db:5432
|
||||
NAME = gitea
|
||||
USER = gitea
|
||||
PASSWD = gitea
|
||||
SSL_MODE = disable
|
||||
|
||||
[repository]
|
||||
ROOT = /data/git/repositories
|
||||
|
||||
[security]
|
||||
INSTALL_LOCK = true
|
||||
|
||||
[service]
|
||||
DISABLE_REGISTRATION = false
|
||||
REQUIRE_SIGNIN_VIEW = true
|
||||
|
||||
[indexer]
|
||||
APP_NAME = BeeBrain
|
||||
RUN_MODE = prod
|
||||
RUN_USER = git
|
||||
|
||||
[server]
|
||||
DOMAIN = bee8333.ddns.net
|
||||
SSH_DOMAIN = bee8333.ddns.net
|
||||
HTTP_PORT = 3000
|
||||
ROOT_URL = https://bee8333.ddns.net/
|
||||
DISABLE_SSH = false
|
||||
SSH_PORT = 222
|
||||
SSH_LISTEN_PORT = 22
|
||||
LFS_START_SERVER = true
|
||||
PROTOCOL = https
|
||||
CERT_FILE = /data/gitea/cert.pem
|
||||
KEY_FILE = /data/gitea/key.pem
|
||||
|
||||
[database]
|
||||
DB_TYPE = postgres
|
||||
HOST = db:5432
|
||||
NAME = gitea
|
||||
USER = gitea
|
||||
PASSWD = gitea
|
||||
SSL_MODE = disable
|
||||
|
||||
[repository]
|
||||
ROOT = /data/git/repositories
|
||||
|
||||
[security]
|
||||
INSTALL_LOCK = true
|
||||
|
||||
[service]
|
||||
DISABLE_REGISTRATION = false
|
||||
REQUIRE_SIGNIN_VIEW = true
|
||||
|
||||
[indexer]
|
||||
ISSUE_INDEXER_PATH = /data/gitea/indexers/issues.bleve
|
||||
54
headscale/config/config.yaml
Normal file
54
headscale/config/config.yaml
Normal file
@@ -0,0 +1,54 @@
|
||||
server_url: https://bee8333.ddns.net/headscale/
|
||||
listen_addr: 0.0.0.0:8080
|
||||
metrics_listen_addr: 127.0.0.1:9090
|
||||
grpc_listen_addr: 0.0.0.0:50443
|
||||
grpc_allow_insecure: false
|
||||
|
||||
tls_cert_path: ""
|
||||
tls_key_path: ""
|
||||
|
||||
private_key_path: /var/lib/headscale/private.key
|
||||
noise:
|
||||
private_key_path: /var/lib/headscale/noise_private.key
|
||||
|
||||
prefixes:
|
||||
v4: 100.64.0.0/10
|
||||
v6: fd7a:115c:a1e0::/48
|
||||
|
||||
derp:
|
||||
server:
|
||||
enabled: true
|
||||
region_id: 900
|
||||
region_code: "homelab"
|
||||
region_name: "Home Lab"
|
||||
stun_listen_addr: "0.0.0.0:3478"
|
||||
private_key_path: /var/lib/headscale/derp_server_private.key
|
||||
urls:
|
||||
- https://controlplane.tailscale.com/derpmap/default
|
||||
|
||||
disable_check_updates: false
|
||||
ephemeral_node_inactivity_timeout: 30m
|
||||
database:
|
||||
type: sqlite3
|
||||
sqlite:
|
||||
path: /var/lib/headscale/db.sqlite
|
||||
|
||||
log:
|
||||
format: text
|
||||
level: info
|
||||
|
||||
policy:
|
||||
path: ""
|
||||
|
||||
dns:
|
||||
override_local_dns: true
|
||||
nameservers:
|
||||
global:
|
||||
- 1.1.1.1
|
||||
- 8.8.8.8
|
||||
search_domains: []
|
||||
magic_dns: true
|
||||
base_domain: headscale.bee8333.local
|
||||
|
||||
unix_socket: /var/run/headscale/headscale.sock
|
||||
unix_socket_permission: "0770"
|
||||
36
immich-https.conf
Normal file
36
immich-https.conf
Normal file
@@ -0,0 +1,36 @@
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
upstream immich {
|
||||
server immich_server:2283;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name bee8333.ddns.net;
|
||||
|
||||
# Self-signed SSL certificate (will be generated at startup)
|
||||
ssl_certificate /etc/ssl/certs/immich.crt;
|
||||
ssl_certificate_key /etc/ssl/private/immich.key;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers HIGH:!aNULL:!MD5;
|
||||
|
||||
client_max_body_size 50000M;
|
||||
|
||||
# Direct proxy to Immich - NO subpath manipulation
|
||||
location / {
|
||||
proxy_pass http://immich;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
|
||||
# WebSocket support for real-time features
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
}
|
||||
}
|
||||
}
|
||||
49
immich-nginx.conf
Normal file
49
immich-nginx.conf
Normal file
@@ -0,0 +1,49 @@
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
upstream immich {
|
||||
server immich_server:2283;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name bee8333.ddns.net;
|
||||
|
||||
client_max_body_size 50000M;
|
||||
|
||||
# Main application - all requests go to Immich
|
||||
location / {
|
||||
proxy_pass http://immich;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# Critical headers for subpath handling
|
||||
proxy_set_header X-Forwarded-Prefix /immich;
|
||||
proxy_set_header X-Script-Name /immich;
|
||||
|
||||
# WebSocket support for real-time features
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
|
||||
# SPA support - handle client-side routing
|
||||
proxy_intercept_errors on;
|
||||
error_page 404 = @fallback;
|
||||
}
|
||||
|
||||
# Fallback for SPA routing
|
||||
location @fallback {
|
||||
proxy_pass http://immich;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Prefix /immich;
|
||||
proxy_set_header X-Script-Name /immich;
|
||||
}
|
||||
}
|
||||
}
|
||||
248
ob.md
248
ob.md
@@ -1,125 +1,125 @@
|
||||
# Setting Up Git Access with Gitea and Obsidian
|
||||
|
||||
## Part 1: Authorizing Git Client Access
|
||||
|
||||
### Prerequisites
|
||||
- Gitea instance accessible through your domain (bee8333.ddns.net) via HTTPS
|
||||
- Administrative privileges for initial setup
|
||||
|
||||
### Repository Setup
|
||||
- For new repositories using HTTPS:
|
||||
```bash
|
||||
git clone https://bee8333.ddns.net:3000/username/repository.git
|
||||
```
|
||||
|
||||
- For new repositories using SSH:
|
||||
```bash
|
||||
git clone ssh://git@bee8333.ddns.net:222/username/repository.git
|
||||
```
|
||||
|
||||
- For existing repositories (HTTPS):
|
||||
```bash
|
||||
git remote set-url origin https://bee8333.ddns.net:3000/username/repository.git
|
||||
```
|
||||
|
||||
- For existing repositories (SSH):
|
||||
```bash
|
||||
git remote set-url origin ssh://git@bee8333.ddns.net:222/username/repository.git
|
||||
```
|
||||
|
||||
### Authentication
|
||||
When using HTTPS:
|
||||
1. You'll be prompted for your Gitea username and password
|
||||
2. For better security, create a Personal Access Token in Gitea:
|
||||
- Go to Settings → Applications → Generate New Token
|
||||
- Give it a description
|
||||
- Copy the token immediately (it won't be shown again)
|
||||
- Use this token as your password when Git asks for credentials
|
||||
|
||||
When using SSH:
|
||||
1. Generate an SSH key pair if you haven't already:
|
||||
```bash
|
||||
ssh-keygen -t ed25519 -C "your_email@example.com"
|
||||
```
|
||||
2. Add your public key to Gitea:
|
||||
- Go to Settings → SSH / GPG Keys
|
||||
- Click "Add Key"
|
||||
- Paste your public key (from ~/.ssh/id_ed25519.pub)
|
||||
3. SSH will use your key automatically for authentication
|
||||
|
||||
### Important Note
|
||||
When using non-standard HTTPS ports (like 3000):
|
||||
1. Use an elevated (Administrator) PowerShell/Command Prompt for Git operations
|
||||
2. Regular terminals in VS Code/Cursor may not have sufficient privileges
|
||||
3. If Git operations fail, try running your terminal as Administrator
|
||||
|
||||
## Part 2: Obsidian-Git Integration
|
||||
|
||||
### Plugin Installation
|
||||
1. Open Obsidian Settings → Community plugins
|
||||
2. Search for "Obsidian Git"
|
||||
3. Install and enable the plugin
|
||||
|
||||
### Plugin Configuration
|
||||
1. Go to Settings → Community plugins → Obsidian Git
|
||||
2. Recommended settings:
|
||||
- ❌ Auto pull interval (disable when using Syncthing)
|
||||
- ✅ Show status bar
|
||||
- ✅ Source Control View
|
||||
- ✅ Show changes files count in status bar
|
||||
- Configure default commit message
|
||||
|
||||
### Essential Commands
|
||||
Access these via Command Palette (Ctrl/Cmd + P):
|
||||
- `Open source control view` - View changes and branch info
|
||||
- `List changed files` - See modifications
|
||||
- `View diff` - Check file changes
|
||||
- `Stage/Unstage current file` - Prepare for commit
|
||||
- `Commit staged` - Save staged changes
|
||||
- `Create/Switch branch` - Branch management
|
||||
|
||||
### Recommended Workflow
|
||||
1. Make changes in Obsidian
|
||||
2. Check Source Control View
|
||||
3. Stage desired files
|
||||
4. Commit with meaningful message
|
||||
5. Push to Gitea
|
||||
|
||||
### Status Bar Features
|
||||
- Current branch name
|
||||
- Number of changed files
|
||||
- Sync status indicators
|
||||
|
||||
## Important Configuration
|
||||
|
||||
### Gitignore Setup
|
||||
Add these patterns to `.gitignore`:
|
||||
```
|
||||
.trash/
|
||||
.stversions/
|
||||
.obsidian/workspace.json
|
||||
.obsidian/workspace-mobile.json
|
||||
```
|
||||
|
||||
### Security Best Practices
|
||||
- Keep SSH private keys secure
|
||||
- Use strong SSH key passphrases
|
||||
- Regularly review and clean up SSH keys in Gitea
|
||||
- Never share private keys
|
||||
|
||||
### Syncthing Compatibility
|
||||
- Wait for Syncthing sync before Git operations
|
||||
- Commit/push before closing Obsidian
|
||||
- Ensure `.stversions` is in `.gitignore`
|
||||
|
||||
### Performance Tips
|
||||
- Stage files individually
|
||||
- Use branches for major changes
|
||||
- Commit regularly, push selectively
|
||||
- Monitor Source Control View
|
||||
|
||||
## Collaboration Guidelines
|
||||
- Pull before making changes
|
||||
- Use branches for significant changes
|
||||
- Check diff view for conflicts
|
||||
# Setting Up Git Access with Gitea and Obsidian
|
||||
|
||||
## Part 1: Authorizing Git Client Access
|
||||
|
||||
### Prerequisites
|
||||
- Gitea instance accessible through your domain (bee8333.ddns.net) via HTTPS
|
||||
- Administrative privileges for initial setup
|
||||
|
||||
### Repository Setup
|
||||
- For new repositories using HTTPS:
|
||||
```bash
|
||||
git clone https://bee8333.ddns.net:3000/username/repository.git
|
||||
```
|
||||
|
||||
- For new repositories using SSH:
|
||||
```bash
|
||||
git clone ssh://git@bee8333.ddns.net:222/username/repository.git
|
||||
```
|
||||
|
||||
- For existing repositories (HTTPS):
|
||||
```bash
|
||||
git remote set-url origin https://bee8333.ddns.net:3000/username/repository.git
|
||||
```
|
||||
|
||||
- For existing repositories (SSH):
|
||||
```bash
|
||||
git remote set-url origin ssh://git@bee8333.ddns.net:222/username/repository.git
|
||||
```
|
||||
|
||||
### Authentication
|
||||
When using HTTPS:
|
||||
1. You'll be prompted for your Gitea username and password
|
||||
2. For better security, create a Personal Access Token in Gitea:
|
||||
- Go to Settings → Applications → Generate New Token
|
||||
- Give it a description
|
||||
- Copy the token immediately (it won't be shown again)
|
||||
- Use this token as your password when Git asks for credentials
|
||||
|
||||
When using SSH:
|
||||
1. Generate an SSH key pair if you haven't already:
|
||||
```bash
|
||||
ssh-keygen -t ed25519 -C "your_email@example.com"
|
||||
```
|
||||
2. Add your public key to Gitea:
|
||||
- Go to Settings → SSH / GPG Keys
|
||||
- Click "Add Key"
|
||||
- Paste your public key (from ~/.ssh/id_ed25519.pub)
|
||||
3. SSH will use your key automatically for authentication
|
||||
|
||||
### Important Note
|
||||
When using non-standard HTTPS ports (like 3000):
|
||||
1. Use an elevated (Administrator) PowerShell/Command Prompt for Git operations
|
||||
2. Regular terminals in VS Code/Cursor may not have sufficient privileges
|
||||
3. If Git operations fail, try running your terminal as Administrator
|
||||
|
||||
## Part 2: Obsidian-Git Integration
|
||||
|
||||
### Plugin Installation
|
||||
1. Open Obsidian Settings → Community plugins
|
||||
2. Search for "Obsidian Git"
|
||||
3. Install and enable the plugin
|
||||
|
||||
### Plugin Configuration
|
||||
1. Go to Settings → Community plugins → Obsidian Git
|
||||
2. Recommended settings:
|
||||
- ❌ Auto pull interval (disable when using Syncthing)
|
||||
- ✅ Show status bar
|
||||
- ✅ Source Control View
|
||||
- ✅ Show changes files count in status bar
|
||||
- Configure default commit message
|
||||
|
||||
### Essential Commands
|
||||
Access these via Command Palette (Ctrl/Cmd + P):
|
||||
- `Open source control view` - View changes and branch info
|
||||
- `List changed files` - See modifications
|
||||
- `View diff` - Check file changes
|
||||
- `Stage/Unstage current file` - Prepare for commit
|
||||
- `Commit staged` - Save staged changes
|
||||
- `Create/Switch branch` - Branch management
|
||||
|
||||
### Recommended Workflow
|
||||
1. Make changes in Obsidian
|
||||
2. Check Source Control View
|
||||
3. Stage desired files
|
||||
4. Commit with meaningful message
|
||||
5. Push to Gitea
|
||||
|
||||
### Status Bar Features
|
||||
- Current branch name
|
||||
- Number of changed files
|
||||
- Sync status indicators
|
||||
|
||||
## Important Configuration
|
||||
|
||||
### Gitignore Setup
|
||||
Add these patterns to `.gitignore`:
|
||||
```
|
||||
.trash/
|
||||
.stversions/
|
||||
.obsidian/workspace.json
|
||||
.obsidian/workspace-mobile.json
|
||||
```
|
||||
|
||||
### Security Best Practices
|
||||
- Keep SSH private keys secure
|
||||
- Use strong SSH key passphrases
|
||||
- Regularly review and clean up SSH keys in Gitea
|
||||
- Never share private keys
|
||||
|
||||
### Syncthing Compatibility
|
||||
- Wait for Syncthing sync before Git operations
|
||||
- Commit/push before closing Obsidian
|
||||
- Ensure `.stversions` is in `.gitignore`
|
||||
|
||||
### Performance Tips
|
||||
- Stage files individually
|
||||
- Use branches for major changes
|
||||
- Commit regularly, push selectively
|
||||
- Monitor Source Control View
|
||||
|
||||
## Collaboration Guidelines
|
||||
- Pull before making changes
|
||||
- Use branches for significant changes
|
||||
- Check diff view for conflicts
|
||||
- Let Syncthing sync complete before Git operations
|
||||
@@ -1,67 +1,67 @@
|
||||
# Gitea Database Restore Script
|
||||
param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$BackupFile
|
||||
)
|
||||
|
||||
# Check if backup file exists
|
||||
if (-not (Test-Path $BackupFile)) {
|
||||
Write-Host "Backup file not found: $BackupFile" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Extract the backup if it's a zip file
|
||||
$tempFile = $null
|
||||
if ($BackupFile.EndsWith(".zip")) {
|
||||
$tempDir = [System.IO.Path]::GetTempPath()
|
||||
$tempFile = Join-Path $tempDir "gitea-db-restore-temp.sql"
|
||||
|
||||
Write-Host "Extracting backup file..."
|
||||
Expand-Archive -Path $BackupFile -DestinationPath $tempDir -Force
|
||||
$extractedFile = Get-ChildItem -Path $tempDir -Filter "*.sql" | Select-Object -First 1
|
||||
|
||||
if ($extractedFile) {
|
||||
Copy-Item $extractedFile.FullName -Destination $tempFile
|
||||
$BackupFile = $tempFile
|
||||
} else {
|
||||
Write-Host "Failed to extract SQL file from backup" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Confirm before proceeding
|
||||
Write-Host "WARNING: This will overwrite the current database with the backup." -ForegroundColor Yellow
|
||||
Write-Host "Make sure your Gitea service is stopped before proceeding." -ForegroundColor Yellow
|
||||
$confirmation = Read-Host "Do you want to continue? (y/n)"
|
||||
|
||||
if ($confirmation -ne "y") {
|
||||
Write-Host "Restore cancelled."
|
||||
if ($tempFile -and (Test-Path $tempFile)) {
|
||||
Remove-Item $tempFile
|
||||
}
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Stop Gitea services
|
||||
Write-Host "Stopping Gitea services..."
|
||||
docker-compose stop
|
||||
|
||||
# Restore the database
|
||||
Write-Host "Restoring database from backup..."
|
||||
Get-Content $BackupFile | docker exec -i gitea-db psql -U gitea -d gitea
|
||||
|
||||
# Check restore status
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host "Database restore completed successfully!" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Database restore failed!" -ForegroundColor Red
|
||||
}
|
||||
|
||||
# Clean up temp file if created
|
||||
if ($tempFile -and (Test-Path $tempFile)) {
|
||||
Remove-Item $tempFile
|
||||
}
|
||||
|
||||
# Restart Gitea services
|
||||
Write-Host "Starting Gitea services..."
|
||||
# Gitea Database Restore Script
|
||||
param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$BackupFile
|
||||
)
|
||||
|
||||
# Check if backup file exists
|
||||
if (-not (Test-Path $BackupFile)) {
|
||||
Write-Host "Backup file not found: $BackupFile" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Extract the backup if it's a zip file
|
||||
$tempFile = $null
|
||||
if ($BackupFile.EndsWith(".zip")) {
|
||||
$tempDir = [System.IO.Path]::GetTempPath()
|
||||
$tempFile = Join-Path $tempDir "gitea-db-restore-temp.sql"
|
||||
|
||||
Write-Host "Extracting backup file..."
|
||||
Expand-Archive -Path $BackupFile -DestinationPath $tempDir -Force
|
||||
$extractedFile = Get-ChildItem -Path $tempDir -Filter "*.sql" | Select-Object -First 1
|
||||
|
||||
if ($extractedFile) {
|
||||
Copy-Item $extractedFile.FullName -Destination $tempFile
|
||||
$BackupFile = $tempFile
|
||||
} else {
|
||||
Write-Host "Failed to extract SQL file from backup" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Confirm before proceeding
|
||||
Write-Host "WARNING: This will overwrite the current database with the backup." -ForegroundColor Yellow
|
||||
Write-Host "Make sure your Gitea service is stopped before proceeding." -ForegroundColor Yellow
|
||||
$confirmation = Read-Host "Do you want to continue? (y/n)"
|
||||
|
||||
if ($confirmation -ne "y") {
|
||||
Write-Host "Restore cancelled."
|
||||
if ($tempFile -and (Test-Path $tempFile)) {
|
||||
Remove-Item $tempFile
|
||||
}
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Stop Gitea services
|
||||
Write-Host "Stopping Gitea services..."
|
||||
docker-compose stop
|
||||
|
||||
# Restore the database
|
||||
Write-Host "Restoring database from backup..."
|
||||
Get-Content $BackupFile | docker exec -i gitea-db psql -U gitea -d gitea
|
||||
|
||||
# Check restore status
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host "Database restore completed successfully!" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Database restore failed!" -ForegroundColor Red
|
||||
}
|
||||
|
||||
# Clean up temp file if created
|
||||
if ($tempFile -and (Test-Path $tempFile)) {
|
||||
Remove-Item $tempFile
|
||||
}
|
||||
|
||||
# Restart Gitea services
|
||||
Write-Host "Starting Gitea services..."
|
||||
docker-compose start
|
||||
@@ -1,88 +1,88 @@
|
||||
# Script to restore the Postgres Docker volume from a backup
|
||||
param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$BackupFile
|
||||
)
|
||||
|
||||
$volumeName = "gitea-docker_postgres-data"
|
||||
$tempDir = Join-Path $env:TEMP "postgres-volume-restore"
|
||||
|
||||
# Check if backup file exists
|
||||
if (-not (Test-Path $BackupFile)) {
|
||||
Write-Host "Backup file not found: $BackupFile" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Extract the backup if it's a zip file
|
||||
$tarFile = $BackupFile
|
||||
if ($BackupFile.EndsWith(".zip")) {
|
||||
# Create temp directory if it doesn't exist
|
||||
if (-not (Test-Path $tempDir)) {
|
||||
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
|
||||
} else {
|
||||
# Clean temp directory
|
||||
Remove-Item -Path "$tempDir\*" -Force -Recurse -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
Write-Host "Extracting backup file..."
|
||||
Expand-Archive -Path $BackupFile -DestinationPath $tempDir -Force
|
||||
$extractedFile = Get-ChildItem -Path $tempDir -Filter "*.tar" | Select-Object -First 1
|
||||
|
||||
if ($extractedFile) {
|
||||
$tarFile = $extractedFile.FullName
|
||||
} else {
|
||||
Write-Host "Failed to extract TAR file from backup" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Confirm before proceeding
|
||||
Write-Host "WARNING: This will overwrite the current database volume with the backup." -ForegroundColor Yellow
|
||||
Write-Host "Make sure your Gitea services are stopped before proceeding." -ForegroundColor Yellow
|
||||
$confirmation = Read-Host "Do you want to continue? (y/n)"
|
||||
|
||||
if ($confirmation -ne "y") {
|
||||
Write-Host "Restore cancelled."
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Stop Gitea services
|
||||
Write-Host "Stopping Gitea services..."
|
||||
docker-compose down
|
||||
|
||||
# Check if volume exists and remove it
|
||||
$volumeExists = docker volume ls --format "{{.Name}}" | Select-String -Pattern "^$volumeName$"
|
||||
if ($volumeExists) {
|
||||
Write-Host "Removing existing volume $volumeName..."
|
||||
docker volume rm $volumeName
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "Failed to remove existing volume. It might be in use by another container." -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Create a new volume
|
||||
Write-Host "Creating new volume $volumeName..."
|
||||
docker volume create $volumeName
|
||||
|
||||
# Restore from backup
|
||||
Write-Host "Restoring volume from backup..."
|
||||
docker run --rm -v ${volumeName}:/volume -v ${tarFile}:/backup.tar alpine sh -c "cd /volume && tar -xf /backup.tar"
|
||||
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host "Volume restore completed successfully!" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Volume restore failed!" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Clean up temp directory if created
|
||||
if ($BackupFile.EndsWith(".zip") -and (Test-Path $tempDir)) {
|
||||
Remove-Item -Path $tempDir -Force -Recurse -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
# Start Gitea services
|
||||
Write-Host "Starting Gitea services..."
|
||||
docker-compose up -d
|
||||
|
||||
# Script to restore the Postgres Docker volume from a backup
|
||||
param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$BackupFile
|
||||
)
|
||||
|
||||
$volumeName = "gitea-docker_postgres-data"
|
||||
$tempDir = Join-Path $env:TEMP "postgres-volume-restore"
|
||||
|
||||
# Check if backup file exists
|
||||
if (-not (Test-Path $BackupFile)) {
|
||||
Write-Host "Backup file not found: $BackupFile" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Extract the backup if it's a zip file
|
||||
$tarFile = $BackupFile
|
||||
if ($BackupFile.EndsWith(".zip")) {
|
||||
# Create temp directory if it doesn't exist
|
||||
if (-not (Test-Path $tempDir)) {
|
||||
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
|
||||
} else {
|
||||
# Clean temp directory
|
||||
Remove-Item -Path "$tempDir\*" -Force -Recurse -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
Write-Host "Extracting backup file..."
|
||||
Expand-Archive -Path $BackupFile -DestinationPath $tempDir -Force
|
||||
$extractedFile = Get-ChildItem -Path $tempDir -Filter "*.tar" | Select-Object -First 1
|
||||
|
||||
if ($extractedFile) {
|
||||
$tarFile = $extractedFile.FullName
|
||||
} else {
|
||||
Write-Host "Failed to extract TAR file from backup" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Confirm before proceeding
|
||||
Write-Host "WARNING: This will overwrite the current database volume with the backup." -ForegroundColor Yellow
|
||||
Write-Host "Make sure your Gitea services are stopped before proceeding." -ForegroundColor Yellow
|
||||
$confirmation = Read-Host "Do you want to continue? (y/n)"
|
||||
|
||||
if ($confirmation -ne "y") {
|
||||
Write-Host "Restore cancelled."
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Stop Gitea services
|
||||
Write-Host "Stopping Gitea services..."
|
||||
docker-compose down
|
||||
|
||||
# Check if volume exists and remove it
|
||||
$volumeExists = docker volume ls --format "{{.Name}}" | Select-String -Pattern "^$volumeName$"
|
||||
if ($volumeExists) {
|
||||
Write-Host "Removing existing volume $volumeName..."
|
||||
docker volume rm $volumeName
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "Failed to remove existing volume. It might be in use by another container." -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Create a new volume
|
||||
Write-Host "Creating new volume $volumeName..."
|
||||
docker volume create $volumeName
|
||||
|
||||
# Restore from backup
|
||||
Write-Host "Restoring volume from backup..."
|
||||
docker run --rm -v ${volumeName}:/volume -v ${tarFile}:/backup.tar alpine sh -c "cd /volume && tar -xf /backup.tar"
|
||||
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host "Volume restore completed successfully!" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Volume restore failed!" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Clean up temp directory if created
|
||||
if ($BackupFile.EndsWith(".zip") -and (Test-Path $tempDir)) {
|
||||
Remove-Item -Path $tempDir -Force -Recurse -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
# Start Gitea services
|
||||
Write-Host "Starting Gitea services..."
|
||||
docker-compose up -d
|
||||
|
||||
Write-Host "Restore process completed. Check if your Gitea instance is working properly." -ForegroundColor Green
|
||||
@@ -1,17 +1,17 @@
|
||||
# This script is automatically generated - do not edit manually
|
||||
# It runs the Docker check script followed by database and volume backup scripts
|
||||
|
||||
# Get the script directory
|
||||
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
|
||||
# Run the Docker check script first
|
||||
$dockerCheckScript = Join-Path $scriptDir "ensure-docker-running.ps1"
|
||||
& $dockerCheckScript
|
||||
|
||||
# Then run the database backup script
|
||||
$dbBackupScript = Join-Path $scriptDir "backup-gitea-db.ps1"
|
||||
& $dbBackupScript
|
||||
|
||||
# Finally run the volume backup script
|
||||
$volumeBackupScript = Join-Path $scriptDir "backup-volume.ps1"
|
||||
& $volumeBackupScript
|
||||
# This script is automatically generated - do not edit manually
|
||||
# It runs the Docker check script followed by database and volume backup scripts
|
||||
|
||||
# Get the script directory
|
||||
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
|
||||
# Run the Docker check script first
|
||||
$dockerCheckScript = Join-Path $scriptDir "ensure-docker-running.ps1"
|
||||
& $dockerCheckScript
|
||||
|
||||
# Then run the database backup script
|
||||
$dbBackupScript = Join-Path $scriptDir "backup-gitea-db.ps1"
|
||||
& $dbBackupScript
|
||||
|
||||
# Finally run the volume backup script
|
||||
$volumeBackupScript = Join-Path $scriptDir "backup-volume.ps1"
|
||||
& $volumeBackupScript
|
||||
|
||||
@@ -1,67 +1,67 @@
|
||||
# Script to create a scheduled task for Gitea database backups
|
||||
$workingDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$scriptPath = Join-Path $workingDir "backup-gitea-db.ps1"
|
||||
$dockerCheckScript = Join-Path $workingDir "ensure-docker-running.ps1"
|
||||
$taskName = "GiteaDatabaseBackup"
|
||||
$taskDescription = "Regular backup of Gitea PostgreSQL database"
|
||||
|
||||
# Check if the backup script exists
|
||||
if (-not (Test-Path $scriptPath)) {
|
||||
Write-Host "Backup script not found at: $scriptPath" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check if the Docker check script exists
|
||||
if (-not (Test-Path $dockerCheckScript)) {
|
||||
Write-Host "Docker check script not found at: $dockerCheckScript" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Create a batch script that runs both scripts
|
||||
$batchScriptPath = Join-Path $workingDir "run-backup.ps1"
|
||||
@"
|
||||
# This script is automatically generated - do not edit manually
|
||||
# It runs the Docker check script followed by the backup script
|
||||
|
||||
# Get the script directory
|
||||
`$scriptDir = Split-Path -Parent `$MyInvocation.MyCommand.Path
|
||||
|
||||
# Run the Docker check script first
|
||||
`$dockerCheckScript = Join-Path `$scriptDir "ensure-docker-running.ps1"
|
||||
& `$dockerCheckScript
|
||||
|
||||
# Then run the backup script
|
||||
`$backupScript = Join-Path `$scriptDir "backup-gitea-db.ps1"
|
||||
& `$backupScript
|
||||
"@ | Out-File -FilePath $batchScriptPath -Encoding utf8
|
||||
|
||||
# Create a scheduled task to run daily at 3 AM
|
||||
$action = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -File `"$batchScriptPath`"" -WorkingDirectory "$workingDir"
|
||||
$trigger = New-ScheduledTaskTrigger -Daily -At 3AM
|
||||
$settings = New-ScheduledTaskSettingsSet -StartWhenAvailable -DontStopOnIdleEnd -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries
|
||||
|
||||
# Create a principal that runs with highest privileges
|
||||
$principal = New-ScheduledTaskPrincipal -UserId "NT AUTHORITY\SYSTEM" -LogonType ServiceAccount -RunLevel Highest
|
||||
|
||||
# Register the scheduled task
|
||||
$taskExists = Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue
|
||||
|
||||
if ($taskExists) {
|
||||
Write-Host "Task '$taskName' already exists. Updating..." -ForegroundColor Yellow
|
||||
# Get the existing task
|
||||
$task = Get-ScheduledTask -TaskName $taskName
|
||||
# Update the task properties
|
||||
$task.Actions = $action
|
||||
$task.Triggers = $trigger
|
||||
$task.Settings = $settings
|
||||
$task.Principal = $principal
|
||||
$task.Description = $taskDescription
|
||||
# Save the updated task
|
||||
Set-ScheduledTask -InputObject $task
|
||||
} else {
|
||||
Write-Host "Creating new scheduled task '$taskName'..." -ForegroundColor Green
|
||||
Register-ScheduledTask -TaskName $taskName -Action $action -Trigger $trigger -Settings $settings -Description $taskDescription -Principal $principal
|
||||
}
|
||||
|
||||
Write-Host "Scheduled task setup complete. The database will be backed up daily at 3 AM." -ForegroundColor Green
|
||||
# Script to create a scheduled task for Gitea database backups
|
||||
$workingDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$scriptPath = Join-Path $workingDir "backup-gitea-db.ps1"
|
||||
$dockerCheckScript = Join-Path $workingDir "ensure-docker-running.ps1"
|
||||
$taskName = "GiteaDatabaseBackup"
|
||||
$taskDescription = "Regular backup of Gitea PostgreSQL database"
|
||||
|
||||
# Check if the backup script exists
|
||||
if (-not (Test-Path $scriptPath)) {
|
||||
Write-Host "Backup script not found at: $scriptPath" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check if the Docker check script exists
|
||||
if (-not (Test-Path $dockerCheckScript)) {
|
||||
Write-Host "Docker check script not found at: $dockerCheckScript" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Create a batch script that runs both scripts
|
||||
$batchScriptPath = Join-Path $workingDir "run-backup.ps1"
|
||||
@"
|
||||
# This script is automatically generated - do not edit manually
|
||||
# It runs the Docker check script followed by the backup script
|
||||
|
||||
# Get the script directory
|
||||
`$scriptDir = Split-Path -Parent `$MyInvocation.MyCommand.Path
|
||||
|
||||
# Run the Docker check script first
|
||||
`$dockerCheckScript = Join-Path `$scriptDir "ensure-docker-running.ps1"
|
||||
& `$dockerCheckScript
|
||||
|
||||
# Then run the backup script
|
||||
`$backupScript = Join-Path `$scriptDir "backup-gitea-db.ps1"
|
||||
& `$backupScript
|
||||
"@ | Out-File -FilePath $batchScriptPath -Encoding utf8
|
||||
|
||||
# Create a scheduled task to run daily at 3 AM
|
||||
$action = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -File `"$batchScriptPath`"" -WorkingDirectory "$workingDir"
|
||||
$trigger = New-ScheduledTaskTrigger -Daily -At 3AM
|
||||
$settings = New-ScheduledTaskSettingsSet -StartWhenAvailable -DontStopOnIdleEnd -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries
|
||||
|
||||
# Create a principal that runs with highest privileges
|
||||
$principal = New-ScheduledTaskPrincipal -UserId "NT AUTHORITY\SYSTEM" -LogonType ServiceAccount -RunLevel Highest
|
||||
|
||||
# Register the scheduled task
|
||||
$taskExists = Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue
|
||||
|
||||
if ($taskExists) {
|
||||
Write-Host "Task '$taskName' already exists. Updating..." -ForegroundColor Yellow
|
||||
# Get the existing task
|
||||
$task = Get-ScheduledTask -TaskName $taskName
|
||||
# Update the task properties
|
||||
$task.Actions = $action
|
||||
$task.Triggers = $trigger
|
||||
$task.Settings = $settings
|
||||
$task.Principal = $principal
|
||||
$task.Description = $taskDescription
|
||||
# Save the updated task
|
||||
Set-ScheduledTask -InputObject $task
|
||||
} else {
|
||||
Write-Host "Creating new scheduled task '$taskName'..." -ForegroundColor Green
|
||||
Register-ScheduledTask -TaskName $taskName -Action $action -Trigger $trigger -Settings $settings -Description $taskDescription -Principal $principal
|
||||
}
|
||||
|
||||
Write-Host "Scheduled task setup complete. The database will be backed up daily at 3 AM." -ForegroundColor Green
|
||||
Write-Host "Backup files will be stored in the 'backups' folder in your Gitea Docker directory." -ForegroundColor Green
|
||||
Reference in New Issue
Block a user