I'm trying to run my custom backup script through rsnapshot. It simply clones a given git repository to the current working directory. It works fine when run without rsnapshot.
/etc/rsnapshot.config:
backup_script /usr/local/bin/gitbackup.py -r https://foo.bar/myrepo.git -u username -f /root/.pwd git/myrepo.git/
This creates an directory with a .git below myrepo/.git at the backup location and an error:
# rsnapshot -v daily
[...]
error: could not lock config file /var/cache/rsnapshot/tmp/myrepo/.git/config: No such file or directory
fatal: could not set 'remote.origin.fetch' to '+refs/heads/*:refs/remotes/origin/*'
Both, the rsnapshot user and root, got an ~/.gitconfig in their home directories.
Also tried to run it with sudo. This results in:
Cloning into 'myrepo'...
/bin/rm -rf /var/cache/rsnapshot/tmp/
/bin/rm: cannot remove '/var/cache/rsnapshot/tmp/myrepo/.git': Directory not empty
----------------------------------------------------------------------------
rsnapshot encountered an error! The program was invoked with these options:
/usr/bin/rsnapshot -v daily
----------------------------------------------------------------------------
ERROR: Warning! /bin/rm failed.
ERROR: Could not rm_rf("/var/cache/rsnapshot/tmp/");
rm -f /var/run/rsnapshot.pid
fatal: remote-curl: fetch attempted without a local repo
Any idea what's going wrong? Perhaps some env vars for git have to be set?