On Fri, Aug 25, 2023 at 07:24:59AM +0100, Tixy wrote:
On Thu, 2023-08-24 at 22:24 +0000, Russell L. Harris wrote:
#!/bin/bash
# post-commit
# 2023.08.24 2200gmt

ssh backup "git pull"
exit 0

You could omit the 'exit 0' so it returns the error code from the ssh
command, that way you'll get some feedback from failures to backup
which you would probably want to know about.

Thanks; I'll do it.  I have run Debian for over twenty years, but I
have much to learn.

I'm also a bit confused about doing it this way. The usual workflow
with git is to 'push' to the remote repository, which is in fact what
you originally asked how to do.

This particular exercise is aimed at automation; the impetus was a
change of hosts and a move to Debian 12.  I have been opening two
terminals, one on the local host and the other (via SSH) on the remote
host.  Whenever I think it is time to capture the state of the
document I am composing, I commit to the local repository, then I pull
the update into the remote repository.

To me, pull seemed natural, because the remote repository was cloned
from the local.  But if there is a reason to push, then I shall change.

As others pointed out, you push with the command 'git push' which you
could do in the hook script instead of 'ssh backup "git pull"'. But
whatever works for you I guess.

Sounds reasonable.

Note, if you ever edit commits then having an automated 'pull' or
'push' command will fail, as by default they will only do a fast-
forward operation. There are commandline options and config setups to
change this.

That's why I wrote the long description.  The purpose of the system is
to make backups as effortless as possible, and to allow me to
reconsider a paragraph or a page which I deleted yesterday or last
week.  Offhand, I don't know how to edit a commit, or why I would need
to.

RLH

Reply via email to