To git lovers - looking for auto-sync app reddit / selfhosted ---------------------------------------------------------------------- usrdef · 2023-10-03 08:11 Has anyone come across any type of program / docker image that allows for you to specify a folder on your server, and automatically upload that folder to a defined git repo on a set timer that can be modified? I've love to be same to just define a folder, define the repo, give it my Github token, and then every hour or whatever I choose, it just pushes those files right to the repo without any interaction by me. I could make a bash script to do it, but I hate messing with crons, and if there's something already out there, why re-invent the wheel. Spent a few hours poking around on Github for scripts, but the ones I found seem old as hell (like 8 years), and haven't been touched by the developer. Bonus if the script works for any Git repo (like Gitea). ---------------------------------------------------------------------- NikStalwart · 2023-10-03 08:28 I think a program or a docker container for this is too heavy-handed and likely isn't appropriate to your individual usecase. > cron Cron is outdated these days: the new game in town is systemd timers. [Archwiki has good documentation](https://wiki.archlinux.org/index.php/Systemd/Timers). Just set up a simple unit file that runs git commit && git push, and set up the timer. ---------------------------------------------------------------------- usrdef · 2023-10-03 08:35 Interesting, I'll look into this. Right now I'm on Ubuntu, and I absolutely hate using crons. They're an astronomical pain in the ass. ---------------------------------------------------------------------- ElevenNotes · 2023-10-03 09:02 I think using Ubuntu is more the problem here than cron. ---------------------------------------------------------------------- usrdef · 2023-10-03 12:15 I've been with crons on a number of distros, and they just aren't fun in general. Years ago on web design, crons were used for every damn job. One program I was developing had over 70. And they all had to play nice each other. I've seen distros "Duplicate" crons, where you'll have only the one cron registered, yet the system caches the crons and won't stop them. I've had them just flat out not fire. There's just a slew of things crons can fuck up with on any system. And it's about damn time they were phased out. ---------------------------------------------------------------------- ElevenNotes · 2023-10-03 18:22 Just use Alpine Linux. ---------------------------------------------------------------------- xkcd__386 · 2023-10-04 10:31 splitting your question into two parts... - what to run: what you're asking for is literally 3 (very short) shell commands: `git add -A; git commit -m whatever; git push` - when to run it: crontab syntax is not very user-friendly but other than that, I don't see a problem with cron, but if you're more comfortable with systemd that achives the same thing ---------------------------------------------------------------------- usrdef · 2023-10-04 13:00 Yeah, I've always "thought" that doing the commits would be easy. However, I've worked at this a few times, and there always ends up being some type of issue. I also gpg sign, and at random I'll get errors about not being able to sign, or something with the heads missing. It seems like completely random issues. Like here's an example of one script I did months ago. Sometimes it works, and sometimes I get random issues. I even had to add code in there to automatically add an entry to the safe list ``` # ------------------------------------------------------------- # GIT UPDATE # ------------------------------------------------------------- bFoundSafe=false NOW=`date '+%m.%d.%Y %H:%M:%S'`; repo_commit_msg="auto-update - $NOW" repo_branch="main" repo_path="/path/to/repo" repo_name="repo-name" cd $repo_path # see if repo directory is in safelist for git if git config --global --get-all safe.directory | grep -q "$repo_path"; then bFoundSafe=true fi # if new repo, add to safelist if ! $bFoundSafe ; then git config --global --add safe.directory $repo_path fi git config --global user.name "MyUsername" git config --global user.email "email@domain.com" sleep 2s git branch -m $repo_branch git add --all git add -u sleep 5s git commit -S -m "$repo_commit_msg" sleep 5s git push -u origin $repo_branch ``` Obviously this isn't the full script, but just to give an idea of the direction I try to go in. Maybe I'm doing something wrong. I don't remember why I have `git add --all` and `git add -u` but I had an issue and someone recommended that.