2017-09-25 15:31:08 +00:00
|
|
|
You have a git-annex repository, and you want to publish the files
|
|
|
|
in it to the public. One way is to
|
|
|
|
[[setup_a_public_repository_on_a_web_site]], but perhaps you don't have a
|
|
|
|
web server that can run git-annex, and you just want to publish the current
|
|
|
|
files, not the whole git-annex repository.
|
2014-11-28 18:00:46 +00:00
|
|
|
|
2017-09-25 15:31:08 +00:00
|
|
|
The [[git-annex export|git-annex-export]] command is the solution. It lets
|
|
|
|
a tree of files from your git-annex repository be published to Amazon
|
|
|
|
[[special_remotes/S3]], as well as other types of special remotes like
|
|
|
|
[[special_remotes/webdav]] and [[special_remotes/directory]].
|
|
|
|
|
2017-09-25 15:32:44 +00:00
|
|
|
# Publishing to Amazon S3
|
2017-09-25 15:31:08 +00:00
|
|
|
|
|
|
|
Let's create a bucket in Amazon S3 named $BUCKET and a special remote
|
|
|
|
named public-s3. Exporting has to be enabled when setting up a special
|
|
|
|
remote for the first time.
|
2014-11-28 18:00:46 +00:00
|
|
|
|
2017-09-08 20:19:38 +00:00
|
|
|
Set up your special [[S3 remote|special_remotes/S3]] with (at least) these options:
|
2014-11-28 18:00:46 +00:00
|
|
|
|
2017-09-08 20:19:38 +00:00
|
|
|
git annex initremote public-s3 type=s3 encryption=none bucket=$BUCKET exporttree=yes public=yes encryption=none
|
2014-11-28 18:00:46 +00:00
|
|
|
|
2017-09-25 15:31:08 +00:00
|
|
|
Be sure to replace $BUCKET with something like
|
|
|
|
"public-bucket-joey" when you follow along in your shell.
|
|
|
|
|
|
|
|
[[!template id=note text="""
|
|
|
|
Want to only export files in a subdirectory of the master branch?
|
|
|
|
Use `master:subdir`.
|
|
|
|
|
|
|
|
Any git treeish can be used with the export command, so you can also
|
|
|
|
export tags, etc.
|
|
|
|
"""]]
|
|
|
|
|
2017-09-08 20:19:38 +00:00
|
|
|
Then export the files in the master branch to the remote:
|
2014-11-28 18:00:46 +00:00
|
|
|
|
2017-09-08 20:19:38 +00:00
|
|
|
git annex export master --to public-s3
|
2014-11-28 18:00:46 +00:00
|
|
|
|
2017-09-25 15:31:08 +00:00
|
|
|
Each exported file will be available to the public at
|
2017-09-08 20:41:50 +00:00
|
|
|
`http://$BUCKET.s3.amazonaws.com/$FILE`
|
2014-11-28 18:00:46 +00:00
|
|
|
|
2017-09-08 20:19:38 +00:00
|
|
|
Note: Bear in mind that Amazon will charge the owner of the bucket
|
|
|
|
for public downloads from that bucket.
|
2014-11-28 18:00:46 +00:00
|
|
|
|
2017-09-25 15:31:08 +00:00
|
|
|
# Tracking changes to master
|
|
|
|
|
|
|
|
So far, the current contents of the master branch have been exported to
|
|
|
|
public-s3, and to update the export when the branch changes, you have to
|
|
|
|
remember to run `git annex export` again. To automate updating the export,
|
|
|
|
enable tracking.
|
|
|
|
|
|
|
|
git annex export --tracking master --to public-s3
|
|
|
|
|
|
|
|
That tells git-annex that the export should track changes to master.
|
|
|
|
When you run `git annex sync --content`, it will update all tracking
|
|
|
|
exports. The git-annex assistant also automatically updates tracking
|
|
|
|
exports.
|
|
|
|
|
|
|
|
# Amazon S3 indexes
|
2014-11-28 18:00:46 +00:00
|
|
|
|
2017-09-08 21:23:49 +00:00
|
|
|
By default, there is no index.html file exported, so if you open
|
2017-09-08 20:19:38 +00:00
|
|
|
`http://$BUCKET.s3.amazonaws.com/` in a web browser, you'll see an
|
|
|
|
XML document listing the files.
|
2014-11-28 18:00:46 +00:00
|
|
|
|
2017-09-08 20:19:38 +00:00
|
|
|
For a nicer list of files, you can make an index.html file, check it into
|
|
|
|
git, and export it to the bucket. You'll need to configure the bucket to
|
|
|
|
use index.html as its index document, as
|
|
|
|
[explained here](https://stackoverflow.com/questions/27899/is-there-a-way-to-have-index-html-functionality-with-content-hosted-on-s3).
|
2014-11-28 18:00:46 +00:00
|
|
|
|
2017-09-08 20:19:38 +00:00
|
|
|
# Old method
|
2014-11-28 18:00:46 +00:00
|
|
|
|
2017-09-08 20:19:38 +00:00
|
|
|
To use `git annex export`, you need git-annex version 6.20170909 or
|
|
|
|
newer. Before we had `git annex export` an [[old_method]] was used instead.
|