Distribute and manage files with git-annex
Data Warehouse
Git-annex is storage software that distributes files across devices, servers, and cloud services. It can encrypt files and keep everything in sync, and it always knows where to find your data.
If you move into a secluded cabin, you cannot expect a broadband Internet connection. When US Debian developer Joey Hess moved to such a place in 2010, he had to find a way to reconcile his work with his new habitat. He only launched his expensive dial-up connection once a week for cost reasons, but he had a whole bunch of servers with a stack of hard drives to synchronize.
Crowdfunding Success
Because of his situation, Hess began to write a synchronization tool for his own purposes that is now used as the underpinnings for the free Git version control software. This tool is now widely available under the GPL as git-annex [1]. Additionally, thanks to a crowdfunding campaign, Hess has also developed the git-annex assistant
web GUI, which makes the software more accessible for end users. See the "Installation" box for more information.
Installation
Because git-annex was written by a Debian contributor, a current package is always available in the unstable branch (Sid). For the stable Debian version or other distributions, the easiest installation method is to use the precompiled binary archives. The developer always offers the up-to-date version [2]. After unpacking, you need to add the resulting directory, such as ~/bin/git-annex.linux/
, to your PATH
.
Installing the software, which was written in Haskell, with the Cabal package tool is the reserve of experienced Haskell language programmers: My tests revealed some unmet dependencies.
On the git-annex homepage, Hess describes two target groups for the software: Bob the archivist and Alice the globetrotter. The archivist can use git-annex to manage myriad files in a single directory tree, even though the files are spread across multiple servers and even across removable hard drives. For safety reasons, git-annex can also create multiple copies of each file.
In comparison, Alice is permanently on the road with her netbook and USB hard drive and has rented a web server and cloud storage. Git-annex helps Alice find the correct files while she's on the road. All she needs is a WiFi connection in a café; she automatically encrypts the files she stores with the cloud provider.
Git Plus File-Based Storage
In both scenarios, the users benefit from the fact that Git repositories can store and compare data in a decentralized way. However, the version control system was designed for storing many small source files, not for large video files, which cause performance and space problems. The developer's trick: Git-annex only checks in the metadata, along with a symbolic link, in Git. A proprietary storage back end stores the files in the .git/annex/
directory.
Git-annex comes with command-line tools that are quickly and easily learned for technically inclined users, especially if they know Git. The following commands convert the ~/annex
directory into a git-annex repository named My PC:
cd ~/annex git init git annex init "My PC"
Before you can store files in this directory, you need to put it in direct
mode by issuing the git annex direct
command. This is the only mode in which you have access to the files [3]. By default, repositories are in indirect
mode. Then, all data is stored below the hidden .git/
directory.
If you want to add another repository to your file storage, such as a USB stick, the commands in Listing 1 will help. They create the repository on the stick and link the two repositories: Each sees the other side as a remote repository, with which it then synchronizes.
Listing 1
Add Remote
To discover how to add files and hand them over to git-annex for safe keeping, check out Listing 2. The git annex sync
command triggers the data sync.
Listing 2
Adding Files
Many Accessories
In addition to these basic operations, which are described step by step on the git-annex website [4], numerous variations and accessories are available: The repositories supported by the tool, besides local directories and removable media, include remote servers (assuming they offer SSH access), ownCloud, the Google Drive online service, Amazon S3, Box.com, and Rsync.net. For bona fide archivists, the Amazon Glacier offline store and the public Archive.org are also supported.
GnuPG handles encryption, automatically using a locally generated key by default. If desired, however, users can follow GnuPG customs and encrypt with a specific public key.
To make what sounds like a very technical piece of software more accessible to the general public, Hess wrote the git-annex assistant
. This GUI uses a local web server to provide users with a modern web interface in the browser. Additionally, the tool comes with all modern conveniences: The assistant uses the Linux kernel's inotify interface to detect changed files, for example, and to trigger a sync (Figure 1).
The GUI supports the user right from the act of creating the first repository, and it automatically switches the repository to direct
mode. A web form takes the worries out of setting up remote repositories (Figure 2).
The comprehensive documentation on the project website explains many configuration options and provides recommendations for individual use cases. For example, you can assign specific roles to the individual repositories [5]. A client
contains the files that a user accesses during work; transfer
is useful for servers or removable media that are used exclusively for exchanging data, and backup
, as you might guess, keeps everything backed up.
Despite this backup function, Hess insists that git-annex is not classic backup software – it just has backup features as a side effect. With the correct options, you can even tell git-annex to move only MP3 files of less than 100MB to your player. In a screencast [6], the developer demonstrates some of the settings in the Assistant.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.