I don't need k8s and flux just to sync some files to a server
Find a file
Max Bossing 57d0aee97b
All checks were successful
ci/woodpecker/tag/woodpecker Pipeline was successful
[skip ci] add badge to readme
2026-02-18 01:29:17 +01:00
src init 2026-02-18 01:26:32 +01:00
.gitignore init 2026-02-18 01:26:32 +01:00
.woodpecker.yaml init 2026-02-18 01:26:32 +01:00
Cargo.lock rename crate 2026-02-18 01:28:16 +01:00
Cargo.toml rename crate 2026-02-18 01:28:16 +01:00
LICENSE init 2026-02-18 01:26:32 +01:00
README.md [skip ci] add badge to readme 2026-02-18 01:29:17 +01:00
renovate.json init 2026-02-18 01:26:32 +01:00

gitsync

status-badge

gitsync is a simple program that allows you to sync files from git repos to disk. It's part of my blog series on doing everything instead of learning kubernetes.

Why?

I know I know, this just sounds like reimplenting git over git. But I needed a way to simply copy a file if it changed in a repo without actually checking out the whole repo, and also I wanted some niceties which you can read more about further down. This is by no means as advanved as something lile FluxCD, but it still has it's purpose. I primarily use it to synchronise my traefik configs from a git repo to my server so that I can change those without having to edit them via ssh.

Setup

gitsync is deployed as a binary and statically configured through a TOML file. See the example below:

Configuration

Below is an example configuration file for gitsync:

# base url of your forgejo instance. WITHOUT TRAILING SLASH
forgejo_url = "https://git.bossing.vip"
# Authentication token so that gitsync can also see private repos. not needed if you only want public files synced
forgejo_token = "HEHEHEHA"
# delay in seconds for sync checks.
delay = 30

[[File]]
repo = "max/homelab" # The repo in which the file resides
branch = "master" # (optional) the branch in which the file resides
local = "/etc/traefik/config.yaml" # Local destination
remote = "traefik/dynamic.yaml" # location relative to the repository root

[[File]]
repo = "max/homelab"
branch = "master"
local = "/etc/traefik/traefik.yaml"
remote = "traefik/static.yaml"
hook = "docker restart traefik" # Hooks allow you to execute code when the sync finished. In this case, it restarts traefik to reload the static configuration

Gitsyncing the gitsync config.

This sounds kinda backwards, but it's actually pretty neat. There is a special attribute, reload_on_sync for a File that re-initializes the gitsync config after syncing.

If you use this feature, make sure to have the gitsync config as the first item in the config to prevent some weird bugs with partial syncs.

[[File]]
repo = "max/homelab"
branch = "master"
local = "/etc/gitsync.toml" # This has to be the config path of gitsync.
remote = "gitsync.toml" 
reload_on_sync = true # Set this to true to enable reloads

License

MIT