BagIt is a set of hierarchical file system conventions designed to support disk-based storage and network transfer of arbitrary digital content. A "bag" consists of a "payload" (the arbitrary content) and "tags," which are metadata files intended to document the storage and transfer of the bag. A required tag file contains a manifest listing every file in the payload together with its corresponding checksum. The name, BagIt, is inspired by the "enclose and deposit" method, sometimes referred to as "bag it and tag it."

Bags are ideal for digital content normally kept as a collection of files. They are also well-suited to the export, for archival purposes, of content normally kept in database structures that receiving parties are unlikely to support. Relying on cross-platform (Windows and Unix) filesystem naming conventions, a bag's payload may include any number of directories and sub-directories (folders and sub-folders). A bag can specify payload content indirectly via a "fetch.txt" file that lists URLs for content that can be fetched over the network to complete the bag; simple parallelization (e.g. running 10 instances of Wget) can exploit this feature to transfer large bags very quickly. Benefits of bags include:

BagIt

Wide adoption in digital libraries (e.g. the Library of Congress). Easy to implement using ubiquitous and ordinary filesystem tools. Content that originates as files need only be copied to the payload directory. Compared to XML wrapping, content need not be encoded (e.g. Base64), which saves time and storage space. Received content is ready-to-go in a familiar filesystem tree. Easy to implement fast network transfer by running ordinary transfer tools in parallel.

BagIt

Specification

BagIt is currently defined in RFC 8493. It defines a simple file naming convention used by the digital curation community for packaging up arbitrary digital content, so that it can be reliably transported via both physical media (hard disk drive, CD-ROM, DVD) and network transfers (FTP, HTTP, rsync, etc.). BagIt is also used for managing the digital preservation of content over time. Discussion about the specification and its future directions takes place on the Digital Curation discussion list.

BagIt

The BagIt specification is organized around the notion of a "bag." A bag is a named file system directory that minimally contains:

a "data" directory that includes the payload, or data files that comprise the digital content being preserved. Files can also be placed in subdirectories, but empty directories are not supported. at least one manifest file that itemizes the filenames present in the "data" directory, as well as their checksums. The particular checksum algorithm is included as part of the manifest filename. For instance, a manifest file with MD5 checksums is named "manifest-md5.txt." a "bagit.txt" file that identifies the directory as a bag, the version of the BagIt specification that it adheres to, and the character encoding used for tag files.

On receipt of a bag, a piece of software can examine the manifest file to make sure that the payload files are present and that their checksums are correct. This allows for accidentally removed or corrupted files to be identified. Below is an example of a minimal bag "myfirstbag" that encloses two files of payload. The contents of the tag files are included below their filenames.

myfirstbag/

|-- data

| \-- 27613-h

| \-- images

| \-- q172.png

| \-- q172.txt

|-- manifest-md5.txt

| 49afbd86a1ca9f34b677a3f09655eae9 data/27613-h/images/q172.png

| 408ad21d50cef31da4df6d9ed81b01a7 data/27613-h/images/q172.txt

\-- bagit.txt

BagIt-Version: 0.97

Tag-File-Character-Encoding: UTF-8

In this example the payload happens to consist of a Portable Network Graphics image file and an Optical Character Recognition text file. In general the identification and definition of file formats is out of the scope of the BagIt specification; file attributes are likewise out of scope.

The specification allows for several optional tag files (in addition to the manifest). Their character encoding must be identified in "bagit.txt," which itself must always be encoded in UTF-8. The specification defines the following optional tag files:

a "bag-info.txt" file which details metadata for the bag, using colon-separated key/value pairs (similar to HTTP headers) a tag manifest file which lists tag files and their associated checksums (e.g. "tagmanifest-md5.txt") a "fetch.txt" that lists URLs where payload files can be retrieved from in addition or to replace payload files in the "data" directory