Added manual push script for git-sync to sync to all remotes on demand
This commit is contained in:
@@ -434,13 +434,20 @@ The Git-Sync Mirror Agent watches the local repository at `./volumes/repos` and
|
||||
git commit -m "Change 1"
|
||||
\`\`\`
|
||||
|
||||
2. **Monitor Git-Sync Logs**:
|
||||
2. **Manually Push to All Remotes**:
|
||||
To trigger a manual sync to all configured remotes, run:
|
||||
\`\`\`bash
|
||||
./scripts/manual-push-git-sync.sh
|
||||
\`\`\`
|
||||
This script pushes the latest changes to all enabled remotes immediately, bypassing the automated sync interval.
|
||||
|
||||
3. **Monitor Git-Sync Logs**:
|
||||
\`\`\`bash
|
||||
docker logs git_sync_dev --follow
|
||||
\`\`\`
|
||||
You should see the sync process for each configured remote.
|
||||
|
||||
3. **Verify Sync**:
|
||||
4. **Verify Sync**:
|
||||
- **GitHub**: Check your GitHub repository (\`mrhavens/mirror-repo\`).
|
||||
- **Forgejo**: Check \`http://localhost:3000/mrhavens/mirror-repo\`.
|
||||
- **Internet Archive**: Check \`fold-stack-git-mirror\` for Git bundles.
|
||||
@@ -458,7 +465,7 @@ The Git-Sync Mirror Agent watches the local repository at `./volumes/repos` and
|
||||
\`\`\`
|
||||
|
||||
**Logs**:
|
||||
- Logs are stored in \`./volumes/logs\` with filenames like \`sync-<timestamp>.log\`.
|
||||
- Logs are stored in \`./volumes/logs\` with filenames like \`sync-<timestamp>.log\` or \`manual-push-<timestamp>.log\`.
|
||||
|
||||
**Diagnostics**:
|
||||
- Run the diagnostic script to troubleshoot issues:
|
||||
@@ -561,6 +568,4 @@ Contributions are welcome! To contribute:
|
||||
|
||||
## 📅 Last Updated
|
||||
|
||||
This README was last updated on **May 26, 2025, at 09:35 PM CDT**.
|
||||
|
||||
---
|
||||
This README was last updated on **May 26, 2025, at 09:55 PM CDT**.
|
||||
|
||||
Executable
+168
@@ -0,0 +1,168 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo "================================="
|
||||
echo "🚀 GIT-SYNC MANUAL PUSH"
|
||||
echo "================================="
|
||||
echo "📅 Date: Mon May 26 21:43:00 CDT 2025"
|
||||
echo ""
|
||||
|
||||
# Helper function to print success
|
||||
print_success() {
|
||||
echo -e "✅ "
|
||||
}
|
||||
|
||||
# Helper function to print warning
|
||||
print_warning() {
|
||||
echo -e "⚠️ "
|
||||
}
|
||||
|
||||
# Helper function to print error
|
||||
print_error() {
|
||||
echo -e "❌ "
|
||||
}
|
||||
|
||||
# 1. Check if Git-Sync Container is Running
|
||||
if docker ps --format '{{.Names}}' | grep -q "git_sync_dev"; then
|
||||
print_success "Git-Sync container (git_sync_dev) is running."
|
||||
else
|
||||
print_error "Git-Sync container (git_sync_dev) is not running. Start it with: ./scripts/up-dev.sh"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 2. Check Local Repository
|
||||
if docker exec git_sync_dev test -d "/repos/local/.git"; then
|
||||
print_success "Local repository is initialized at /repos/local."
|
||||
else
|
||||
print_error "Local repository not initialized at /repos/local. Initialize it with: git init"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 3. Load Environment Variables
|
||||
if [ -f "config/git-sync/.env" ]; then
|
||||
set -a
|
||||
source config/git-sync/.env
|
||||
set +a
|
||||
else
|
||||
print_error "config/git-sync/.env not found. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 4. Initialize Log File
|
||||
TIMESTAMP=1748313780
|
||||
LOG_FILE="manual-push-.log"
|
||||
docker exec git_sync_dev touch "/logs/"
|
||||
docker exec git_sync_dev chmod 644 "/logs/"
|
||||
docker exec git_sync_dev sh -c "echo '[Mon May 26 21:43:00 CDT 2025] Starting manual push' >> /logs/"
|
||||
|
||||
# Function to log messages
|
||||
log_message() {
|
||||
local level=
|
||||
local message=
|
||||
docker exec git_sync_dev sh -c "echo '[Mon May 26 21:43:00 CDT 2025] [] ' >> /logs/"
|
||||
if [ "" = "INFO" ] && [ "" = "INFO" ]; then
|
||||
echo "[Mon May 26 21:43:00 CDT 2025] [] "
|
||||
elif [ "" = "ERROR" ]; then
|
||||
echo "[Mon May 26 21:43:00 CDT 2025] [] " >&2
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to sync to a Git remote (GitHub/Forgejo)
|
||||
sync_to_git_remote() {
|
||||
local remote_name=
|
||||
local url=
|
||||
log_message "INFO" "Manually syncing to at ..."
|
||||
if docker exec git_sync_dev sh -c "cd /repos/local && git remote | grep -q "; then
|
||||
docker exec git_sync_dev sh -c "cd /repos/local && git remote set-url "
|
||||
else
|
||||
docker exec git_sync_dev sh -c "cd /repos/local && git remote add "
|
||||
fi
|
||||
attempt=1
|
||||
while [ -le ]; do
|
||||
if docker exec git_sync_dev sh -c "cd /repos/local && git push --all --force"; then
|
||||
log_message "INFO" "Successfully synced to ."
|
||||
print_success "Synced to "
|
||||
break
|
||||
else
|
||||
log_message "ERROR" "Failed to sync to (attempt /)."
|
||||
print_error "Failed to sync to (attempt /)"
|
||||
attempt=1
|
||||
sleep 0
|
||||
fi
|
||||
done
|
||||
if [ -gt ]; then
|
||||
log_message "ERROR" "Max retries reached for . Giving up."
|
||||
print_error "Max retries reached for "
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to sync to Radicle
|
||||
sync_to_radicle() {
|
||||
local remote_name=
|
||||
local url=
|
||||
log_message "INFO" "Manually syncing to Radicle at ..."
|
||||
# Placeholder for Radicle sync
|
||||
log_message "INFO" "Radicle sync not fully implemented. Skipping."
|
||||
print_warning "Radicle sync not implemented"
|
||||
}
|
||||
|
||||
# Function to sync to Rclone remote (Internet Archive/Web3.storage)
|
||||
sync_to_rclone_remote() {
|
||||
local remote_name=
|
||||
local url=
|
||||
log_message "INFO" "Manually syncing to at ..."
|
||||
# Create a Git bundle
|
||||
BUNDLE_FILE="/tmp/repo-1748313780.bundle"
|
||||
docker exec git_sync_dev sh -c "cd /repos/local && git bundle create --all"
|
||||
# Sync the bundle using Rclone
|
||||
attempt=1
|
||||
while [ -le ]; do
|
||||
if docker exec git_sync_dev rclone copy --config /config/git-sync/rclone.conf --progress --log-level INFO; then
|
||||
log_message "INFO" "Successfully synced bundle to ."
|
||||
print_success "Synced bundle to "
|
||||
docker exec git_sync_dev rm
|
||||
break
|
||||
else
|
||||
log_message "ERROR" "Failed to sync to (attempt /)."
|
||||
print_error "Failed to sync to (attempt /)"
|
||||
attempt=1
|
||||
sleep 0
|
||||
fi
|
||||
done
|
||||
if [ -gt ]; then
|
||||
log_message "ERROR" "Max retries reached for . Giving up."
|
||||
print_error "Max retries reached for "
|
||||
docker exec git_sync_dev rm
|
||||
fi
|
||||
}
|
||||
|
||||
# 5. Perform Manual Push to All Remotes
|
||||
echo "Pushing to all enabled remotes..."
|
||||
while IFS='|' read -r remote_name type url enabled; do
|
||||
if [ "" -eq 1 ]; then
|
||||
if [ "" = "git" ]; then
|
||||
sync_to_git_remote
|
||||
elif [ "" = "radicle" ]; then
|
||||
sync_to_radicle
|
||||
elif [ "" = "rclone" ]; then
|
||||
sync_to_rclone_remote
|
||||
fi
|
||||
else
|
||||
print_warning "Skipping disabled remote: "
|
||||
fi
|
||||
done < config/git-sync/remotes.conf
|
||||
|
||||
# 6. Summary
|
||||
echo ""
|
||||
echo "================================="
|
||||
echo "✅ Manual Push Completed"
|
||||
echo "================================="
|
||||
echo "Log file: ./volumes/logs/"
|
||||
echo "Check sync status: ./scripts/report-git-sync.sh"
|
||||
echo "Troubleshoot issues: ./scripts/diagnose-git-sync.sh"
|
||||
Reference in New Issue
Block a user