Professional Git Repository Backup and Synchronization System
1.7K
š Professional Git Repository Backup and Synchronization System
A powerful, self-hosted solution for automated Git repository backups across GitHub, GitLab, Gitee, and local storage.
# Pull and run with Docker
docker pull onicc/gitsync:latest
# Create required directories
mkdir -p data backups docker_ssh
# Run the container
docker run -d \
--name gitsync \
-p 8080:8080 \
-v $(pwd)/data:/app/database \
-v $(pwd)/backups:/backups \
-v $(pwd)/docker_ssh:/root/.ssh \
onicc/gitsync:latest
# Access at http://localhost:8080
Real-time monitoring with system statistics and live activity stream.

Manage all your backup tasks with intuitive controls.

Secure SSH key and access token management.

Detailed error logs and troubleshooting information.

The easiest way to deploy GitSync is using the pre-built image from Docker Hub.
docker pull onicc/gitsync:latest
mkdir -p data backups docker_ssh
Create a docker-compose.yml file:
name: gitsync
services:
gitsync:
image: onicc/gitsync:latest
container_name: gitsync
ports:
- "8080:8080"
volumes:
- ./data:/app/database
- ./backups:/backups
- ./docker_ssh:/root/.ssh
environment:
- DATABASE_URL=sqlite:////app/database/git_backup.db
- ENCRYPT_KEY=${ENCRYPT_KEY:-your_secret_key_here}
restart: unless-stopped
docker-compose up -d
Open your browser and navigate to: http://localhost:8080ā
If you want to build the Docker image from source:
git clone https://github.com/Onicc/gitsync.git
cd gitsync
mkdir -p data backups docker_ssh
docker-compose up -d
The application will:
Open your browser and navigate to: http://localhost:8080ā
gitsync/
āāā data/ # Database files (persisted)
āāā backups/ # Backup repositories (persisted)
āāā docker_ssh/ # SSH keys and config (persisted)
āāā docker-compose.yml
āāā Dockerfile
# View logs
docker-compose logs -f
# Stop the application
docker-compose down
# Restart the application
docker-compose restart
# Rebuild and restart
docker-compose up -d --build
# View container status
docker ps | grep gitsync
Local deployment gives you more control and easier debugging.
git clone https://github.com/Onicc/gitsync.git
cd gitsync
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
cd backend
pip install -r requirements.txt
The database will be automatically created on first run.
# From the backend directory
uvicorn main:app --host 0.0.0.0 --port 8080 --reload
Or use Python directly:
python -m uvicorn main:app --host 0.0.0.0 --port 8080 --reload
Open your browser and navigate to: http://localhost:8080ā
gitsync/
āāā backend/
ā āāā main.py
ā āāā database.py
ā āāā models.py
ā āāā git_engine.py
ā āāā scheduler.py
ā āāā api_*.py
ā āāā requirements.txt
āāā frontend/
ā āāā index.html
ā āāā app.js
ā āāā styles.css
āāā database/ # Database files
āāā temp_repos/ # Temporary clone directory
āāā venv/ # Virtual environment
SSH keys are required for authenticating with Git platforms using SSH URLs.
~/.ssh/ (local) or docker_ssh/ (Docker)Personal Access Tokens are required for HTTPS URLs.
repo (full control of private repositories)read_repository, write_repositoryprojects, pull_requestsClick on Sync Tasks in the sidebar.
Click the Add Sync Task button.
[email protected]:username/repo.githttps://github.com/username/repo.git[email protected]:username/backup-repo.git/backups/my-backup (absolute path)0 * * * *0 2 * * *0 3 * * 10 */6 * * *Click Create Task to save. The task will be automatically enabled.
Click the Sync Now button on any backup task to trigger immediate synchronization.
Click the Edit button to modify task configuration.
Click the Delete button to remove a backup task.
Toggle the task status to enable or disable scheduled backups.
The Dashboard shows:
The Diagnostics page provides:
Edit docker-compose.yml to configure:
environment:
- DATABASE_URL=sqlite:////app/database/git_backup.db
- ENCRYPT_KEY=${ENCRYPT_KEY:-your_secret_key_here}
DATABASE_URL: Database connection stringENCRYPT_KEY: Encryption key for storing credentials (change in production)Create a .env file in the backend directory:
DATABASE_URL=sqlite:///./database/git_backup.db
ENCRYPT_KEY=your_secret_key_here
Edit docker-compose.yml:
ports:
- "8080:8080" # Change left side to use different host port
Change the port in the uvicorn command:
uvicorn main:app --host 0.0.0.0 --port 8080
The following directories are mapped to persist data:
volumes:
- ./data:/app/database # Database storage
- ./backups:/backups # Backup repositories
- ./docker_ssh:/root/.ssh # SSH keys and config
Problem: "Host key verification failed"
Solution: The application automatically adds known_hosts on startup. If you still see this error:
# For Docker
docker-compose restart
# For Local
ssh-keyscan github.com >> ~/.ssh/known_hosts
ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
ssh-keyscan gitee.com >> ~/.ssh/known_hosts
Problem: "Permission denied (publickey)"
Solution:
Problem: "Invalid URL format"
Solution:
git@host:username/repository.githttps://host/username/repository.gitProblem: Log timestamps show wrong time
Solution: The application uses local system time. For Docker:
# Add to docker-compose.yml
environment:
- TZ=Asia/Shanghai # Change to your timezone
Problem: "Database is locked"
Solution:
# Stop the application
docker-compose down # or kill the local process
# Remove lock file
rm data/git_backup.db-journal
# Restart
docker-compose up -d
Problem: Docker container in restart loop
Solution:
# Check logs
docker logs gitsync
# Common issues:
# 1. Port already in use - change port in docker-compose.yml
# 2. Permission issues - check directory permissions
# 3. Database corruption - backup and remove data/git_backup.db
ENCRYPT_KEY in productiondata/ directory regularly# Install test dependencies
pip install pytest pytest-asyncio
# Run tests
pytest
backend/
āāā main.py # FastAPI application entry point
āāā database.py # Database initialization and session management
āāā models.py # SQLAlchemy models
āāā git_engine.py # Git operations and sync logic
āāā scheduler.py # APScheduler task scheduling
āāā api_tasks.py # Backup task API endpoints
āāā api_stats.py # Statistics and logs API endpoints
āāā api_credentials.py # Credentials management API endpoints
āāā crypto_utils.py # Encryption utilities
This project is licensed under the MIT License.
Contributions are welcome! Please feel free to submit a Pull Request.
For issues and questions:
Content type
Image
Digest
sha256:d2c1ef69eā¦
Size
108.6 MB
Last updated
9 months ago
docker pull onicc/gitsync