I am trying to backup gitosis and a repository to a backup tarball and then restore and test on a blank system to ensure that in case of complete server failure that I can get a new system running quickly.
I have the two directories using
git clone --mirror gitosis@localhost:gitosis-admin.git gitosis-backup.repo
git clone --mirror gitosis@localhost:test1.git test1-backup.repo
And then taring up
On my cleanly installed machine I have extracted the tarballs and done
git clone gitosis-backup.repo gitosis-admin
git clone test1-backup.repo test1
Going into the the two directories and doing git log shows the history.
But this isn't committed to the new server. But doing git push origin master doesn't work and it claims to be up-to-date.
But any attempt to do a clone from my new server fails as, quite rightly, the repo isn't actually part of the server.
So how do I finish the job? I have been unable to find an answer about restoring gitosis on this site or any other.
Output from testing with the help from VoC is as follows
mkdir git_restore
cd git_restore
mkdir tarballs
cd tarballs
cp ~/backup/*.tgz
tar -zxf gitosis-admin.repo.tgz
tar -zxf test1-backup.repo.tgz
cd ..
mkdir local_repo
cd local_repo
ssh-keygen
sudo apt-get install gitosis
sudo -H -u gitosis gitosis-init < /home/ian/.ssh/id_rsa.pub
ls /srv/gitosis/git # check that this is not a broken sym link
git clone gitosis@localhost:gitosis-admin
cd gitosis-admin
git log # Has the initialise entry
cd ../..
mkdir restore
cd restore
git clone ../tarballs/gitosis-admin.repo gitosis-admin
git clone ../tarballs/test1-backup.repo test1
cd gitosis-admin
git log # Full log is present
git push gitosis@localhost:gitosis-admin master
To gitosis@localhost:gitosis-admin
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'gitosis@localhost:gitosis-admin'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again. See the 'Note about
fast-forwards' section of 'git push --help' for details.
git status
# On branch master
nothing to commit (working directory clean)
git fetch
git merge origin master
Already up-to-date. Yeeah!
git push gitosis@localhost:gitosis-admin master
To gitosis@localhost:gitosis-admin
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'gitosis@localhost:gitosis-admin'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again. See the 'Note about
fast-forwards' section of 'git push --help' for details.
As an aside doing git push gitosis@localhost:gitosis-admin origin/master seems to push, but then if I then do a clone of the gitosis-admin in a separate directory and then do git log then I just have the initialisation entry.