improve tip

This commit is contained in:
Joey Hess 2020-12-28 19:38:12 -04:00
parent 4262ba3c44
commit 4f64c08f32
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -1,25 +1,31 @@
[Borg](https://www.borgbackup.org/) is a deduplicating archiver
with compression and encryption. It can be used with git-annex, as an
unusual kind of special remote. Since borg can efficiently store old
versions of files, storing them in borg, rather than the git-annex
repository can free up disk space.
If your git-annex repository contains 10 versions of a 100 megabyte file,
it will need 1000 megabytes of disk space to store them all. To save space
those old versions can be moved to a remote, but most remotes also don't
store similar versions efficiently.
[Borg](https://www.borgbackup.org/) is a deduplicating archiver
with compression and encryption. This makes it a good solution to this
problem, only the differences between the old versions of the file will be
stored by borg.
Borg can be used with git-annex as an unusual kind of remote.
git-annex is not able to store files in borg itself. Instead the way this
works is you use borg to store your git-annex repository, and then
`git-annex sync` scans the borg repository to find out what annexed files are
stored in it. And when needed, git-annex can retrieve annexed files from
the borg repository.
stored in it.
Let's set that up. Run this from the top directory of your git-annex repository:
Let's set that up. Run this from the top directory of your git-annex repository
to create a borg repository next to it that stores all the files in it, and
let git-annex treat it as a remote.
# borg init --encryption=keyfile ../borgrepo
# git annex initremote borg type=borg borgrepo=../borgrepo
# borg create ../borgrepo `pwd`::{now}
# git annex sync borg
Now git-annex knows that all the files in the repository have been stored
in borg. But when you try to drop a file, you'll find that
git-annex does not trust the borg repository.
Now git-annex knows that all the files in the repository, including all the
old versions, have been stored in borg. But when you try to drop a file,
you'll find that git-annex does not trust the borg repository.
drop file (unsafe)
Could only verify the existence of 0 out of 1 necessary copies
@ -32,21 +38,17 @@ the content of the file from the borg repository at any time, so git-annex
defaults to not trusting it. This is fine when you're using borg to take
backups, and need to delete old borg archives to free up space on the
backup drive. And it can be useful to use git-annex with such borg backups.
But our goal is instead to move old versions of files to borg. So, we need
to decide not to delete things from the borg repository ourselves, and tell
git-annex that we will only use borg to append to the borg repository.
But our goal is instead to move old versions of files to borg. So, you need
to tell git-annex that you will only use borg to append to the borg
repository, not to delete things from it.
# git annex enableremote borg appendonly=yes
Now when you use git-annex to drop files, git-annex will treat the borg
repository as [[a copy|copies]]. Finally, we can move all the old versions
of files to the borg repository.
Now all the old versions of files can be dropped from the git-annex
repository, freeing up disk space.
# git annex unused
# git annex drop --unused
You can continue running `borg create` and `git-annex sync` as your files
changes to store them in borg and let git-annex know what's stored there.
See [[special_remotes/borg]] for more details about using borg as a special
remote.
You can continue running `borg create` and `git-annex sync` to store
changed files in borg and let git-annex know what's stored there.