diff options
| author | Paul Buetow <paul@buetow.org> | 2025-07-03 22:38:37 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-07-03 22:38:37 +0300 |
| commit | 64095a2c8d5a3a72c55d7bd0737c5542a5aeee09 (patch) | |
| tree | 0af2501374550e8fdadd4df00d245c6260c0305d /README.md | |
| parent | 0c072d964d4d07e69d1c0af1f3b09f9adc543571 (diff) | |
feat: add SSH backup locations with --backup flagv0.2.0
- Add support for SSH backup locations (e.g., paul@server:git/)
- Backup locations are one-way only (push only, never pull)
- Automatic bare repository creation on SSH servers
- Add --backup flag to opt-in to backup syncing
- Backup locations are disabled by default for offline resilience
- Update version to 0.2.0
This allows users to maintain private backups on home servers that may
be offline without affecting regular sync operations.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 87 |
1 files changed, 87 insertions, 0 deletions
@@ -20,9 +20,12 @@ GitSyncer is a tool for synchronizing git repositories between multiple organiza - Sync all public repositories from Codeberg to GitHub - Sync all public repositories from GitHub to Codeberg - Automatic repository creation on GitHub and Codeberg +- SSH backup locations with automatic bare repository creation +- One-way backup to private SSH servers (e.g., home NAS) - Merge conflict detection with clear error messages - Never deletes branches (only adds/updates) - GitHub token validation tool +- Opt-in backup mode with --backup flag for resilient offline backups ## Installation @@ -44,6 +47,10 @@ Create a `gitsyncer.json` file: { "host": "git@github.com", "name": "yourusername" + }, + { + "host": "user@nas.local:git", + "backupLocation": true } ], "repositories": [ @@ -58,11 +65,17 @@ Create a `gitsyncer.json` file: ### Sync a single repository ```bash ./gitsyncer --sync repo-name + +# Include backup locations +./gitsyncer --sync repo-name --backup ``` ### Sync all configured repositories ```bash ./gitsyncer --sync-all + +# Include backup locations +./gitsyncer --sync-all --backup ``` ### Sync all public Codeberg repositories to GitHub @@ -112,6 +125,24 @@ Create a `gitsyncer.json` file: ./gitsyncer --version ``` +### The --backup Flag + +The `--backup` flag enables syncing to backup locations configured in your `gitsyncer.json`. This is particularly useful when: +- Your backup server might be offline (e.g., home NAS) +- You want to control when backups happen +- You need to separate regular syncing from backup operations + +Without `--backup`: GitSyncer only syncs between primary git hosts (GitHub, Codeberg, etc.) +With `--backup`: GitSyncer also pushes to backup locations marked with `"backupLocation": true` + +```bash +# Regular sync (backup locations ignored) +./gitsyncer --sync myrepo + +# Sync with backup enabled +./gitsyncer --sync myrepo --backup +``` + ## How It Works 1. GitSyncer clones the repository from the first configured organization @@ -140,6 +171,62 @@ You can exclude branches from synchronization using regex patterns in your confi Excluded branches will be reported during sync but not synchronized. +## SSH Backup Locations + +You can configure SSH backup locations for one-way repository backups to private servers: + +```json +{ + "organizations": [ + { + "host": "git@github.com", + "name": "yourusername" + }, + { + "host": "paul@t450:git", + "backupLocation": true + } + ] +} +``` + +### How SSH Backup Works + +1. **Opt-in feature**: Backup locations are disabled by default. Use the `--backup` flag to enable syncing to them +2. **One-way sync**: Repositories are only pushed TO backup locations, never pulled FROM them +3. **Automatic repository creation**: If a repository doesn't exist on the SSH server, GitSyncer will: + - SSH into the server + - Create the directory structure + - Initialize a bare git repository +4. **Archive functionality**: Repositories that exist only on the backup location are considered archived and won't be synced to other organizations +5. **All branches and tags**: Every branch and tag is pushed to the backup location when `--backup` is used + +### SSH Backup Example + +```bash +# Configure your gitsyncer.json with an SSH backup location +# Backup locations are DISABLED by default to handle offline servers + +# Sync without backup (default behavior) +./gitsyncer --sync myrepo + +# Sync WITH backup enabled +./gitsyncer --sync myrepo --backup + +# Sync all repositories with backup +./gitsyncer --sync-all --backup + +# Full sync with backup +./gitsyncer --full --backup +``` + +The backup location path format is: `user@host:path/REPONAME.git` +- `user@host`: SSH connection string +- `path`: Base directory for repositories +- `REPONAME.git`: Automatically appended repository name + +**Note**: The `--backup` flag is required to sync to backup locations. This allows GitSyncer to work normally even when backup servers are offline or unreachable. + ## Example Workflows ### Sync specific repositories |
