forum/"Preseeding" a special remotegit-annexhttp://git-annex.branchable.com/forum/__34__Preseeding__34___a_special_remote/git-annexikiwiki2014-06-01T13:55:58Zcomment 1http://git-annex.branchable.com/forum/__34__Preseeding__34___a_special_remote/comment_1_b0c46d0eba900d0f6169a2c698d7a222/joeyh.name2014-05-21T17:41:22Z2014-05-21T17:41:22Z
<p>If you also have the files present locally, you can simply do <code>git annex copy --fast --to remote</code>. git-annex copy will first check to see if the remote has the file; seeing that it does it will update the location log.</p>
<p>Another option, if you have shell access on the remote is to simply set up a git repository there, move the files into it and <code>git annex add</code> them, and merge that into your local repository.</p>
<p>There is not currently any way to set the <a href="http://git-annex.branchable.com/location_tracking/">location tracking</a> information to tell git-annex that a file has appeared on a remote. Of course, you can modify the git-annex branch manually to do so. See <a href="http://git-annex.branchable.com/internals/">internals</a>.</p>
Solvedhttp://git-annex.branchable.com/forum/__34__Preseeding__34___a_special_remote/comment_2_5e63f5e6f45c11cc86b293ce8acad77f/Robie2014-06-01T13:55:58Z2014-06-01T13:55:58Z
<p>Thanks to Joey for pointing me in the right direction. I got this working now.</p>
<p>There are approximately three steps:</p>
<ol>
<li><p>Obtain a mapping of git-annex key to friendly name, and rename all entries
in the special remote to their git-annex keys.</p></li>
<li><p>Create and commit symlinks in the <code>master</code> branch (or wherever you want them).</p></li>
<li><p>Add location tracking entries to the <code>git-annex</code> branch for all entries.</p></li>
</ol>
<p>First, I created an "index" file describing the contents of my special remote,
in the form "KEY NAME" where KEY is the git-annex key (I used SHA256) and NAME
is the name I want to use for each file.</p>
<h2>Step 1: Map and rename</h2>
<p>In my case I was "importing" a ddar remote, so I wrote a quick script
(https://github.com/basak/ddar/blob/master/contrib/git-annex-convert.py) to
generate this index as well as rename all ddar archive members to their
git-annex keys instead.</p>
<h2>Step 2: Create and commit symlinks</h2>
<p>Then, I created symlinks in my master branch using:</p>
<pre><code>exec 3<index
while read key name <&3; do ln -s `git annex examinekey --format='.git/annex/objects/${hashdirmixed}${key}/${key}' "$key"` "$name"; git add "$name"; done
git commit -m'Import ddar repository contents'
exec 3<&-
</code></pre>
<h2>Step 3: Add to location tracking</h2>
<p>First I set three variables:</p>
<pre><code>remote_name=ddar # set to the name of the ddar git-annex special remote
uuid=`git config remote."$remote_name".annex-uuid`
now=`printf %6fs $(date +%s)`
</code></pre>
<p>Then I added the entries from <code>index</code> into location tracking as follows:</p>
<pre><code>git checkout git-annex
exec 3<index
while read key name <&3; do log=`git annex examinekey --format='${hashdirlower}${key}.log' "$key"`; mkdir -p `dirname "$log"`; echo "$now 1 $uuid" >> "$log";git add "$log";done
exec 3<&-
git commit -m'Import knowledge of ddar repository contents'
</code></pre>
<h2>Verifying</h2>
<p><code>git-annex fsck --from ddar --fast</code> checks that the keys expected in the
special remote can be found (replace the special remote name as needed).</p>
<p>Skipping <code>--fast</code> will download all data to verify it. I didn't do this -
instead I just sampled one entry which seemed to be OK.</p>