Skip to main content
Browse documentation

Store file content with git-annex

Use a rsync special remote for annexed file content. Keep the Git repository and its history on your computer or your normal Git host; this account stores the content transferred by git-annex.

Install git-annex and rsync locally, then configure the cn-backup SSH alias. Run these commands inside your existing Git repository.

Add the remote​

If this repository has not been initialized for git-annex:

git annex init "my-computer"

Create the storage remote:

git annex initremote cnstorage type=rsync \
rsyncurl=cn-backup:annex encryption=shared

The annex path is relative to the account's rsync root. Keep your Git/annex metadata safe: shared encryption relies on key material stored in that metadata. Do not publish an encrypted repository's key material unintentionally.

Add and copy content​

git annex add ./example-file.zip
git commit -m "Add example file"
git annex copy --to cnstorage ./example-file.zip
git annex whereis ./example-file.zip
git annex fsck --from cnstorage

whereis shows known copies. Check successful transfer and remote integrity before considering removal of any local copy.

Retrieve content​

When a file's content is missing locally but its annex metadata is present:

git annex get --from cnstorage ./example-file.zip

On another clone, configure its SSH alias and run git annex enableremote cnstorage before accessing the existing special remote. Do not create a new unrelated repository at the same remote directory.

Use git-annex commands to manage the stored objects. A normal git push or git-annex-shell connection to the storage account is not the workflow here.

Git-annex's rsync remote reference explains encryption and remote options.