What is the easiest way to do incremental backups of a git repository with git bundle
?
If I just wanted to backup a single branch, I could do something
(We discussed this problem with Jukka, this is the outcome.)
Preliminaries:
backup.bundle
backup
that points at backup.bundle
Making a backup:
git fetch backup
– just to make sure we're up to dategit bundle create newbackup.bundle ^backup/A ^backup/B A B C
^backup/A
-style arguments from refs/remotes/backup/
A
-style arguments are from refs/heads
newbackup.bundle
to wherever you keep your backupsbackup.bundle
with newbackup.bundle
so you know where to start the next incremental backupRecovering:
git remote rm recovery
git remote add recovery <name-of-bundle>
git fetch recovery
– you need to name the remote for this to workrefs/remotes/backup
Seems opqdonut solution will not work, cause ^backup/A ^backup/B only points to last incremental backup. And actually need to exclude refs from all previous incremental backups.
Need to create remotes for each of previous bundles.
UPD: No, it should work, see Jukka comment below.
Try using --since with --all.
Create the first backup:
git bundle create mybundle-all --all
Do an incremental backup:
git bundle create mybundle-inc --since=10.days --all
The incremental should contain all commits on all branches that have happened in the past 10 days. Make sure the --since parameter goes back far enough or you might miss a commit. Git will also refuse to create the bundle if no commits have happened in that time-frame, so plan for that.
You could do
git clone --mirror <your_repo> my-backup.git
It will create a bare repo with all refs.
Then you could periodically do git push --mirror <my-backup>
.