To backup my sql database I have a cron job running that makes a mysql dump. Now I want to create another cron job that commits this dump to the repo, the problem now is that it doesn't work.
In the cron log I see the line where the command gets run but nothing is committed.
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
MAILTO=root
HOME=/
49 16 * * * cd /path/to/backup/folder/ && /usr/local/bin/git commit -am "Updating DB backup"
This is what I put in crontab -e. I also tried this in /etc/crontab, where I put root as user and that works but only as root user which is a problem because of the git post-commit hook that does push after something is commited. Since only my user is allowed to push this doesn't work when root doest the commit.
Since its working with the root user I'm thinking it's a permissions problem, but permissions of what? These commands work in normal command line.
When catching the stdout and stderr I get the following in the log.
Permission denied (publickey).^M
fatal: The remote end hung up unexpectedly
so it doesn't really runs as my user or can't find the key?
push
andcommit
interchangeably and they have nothing in common. For example, I could see a problem with push if it where pushing to a remote ssh target as root, just like root access to any server might be blocked. If you just focus on commit, that's updating the local index, which you likely own e.g..git/
, so permissions shouldn't matter at all there. Also please provide the cron logs surrounding the incident.