| -rw-r--r-- | recover.in | 7 | ||||
| -rw-r--r-- | remote.in | 35 |
2 files changed, 15 insertions, 27 deletions
@@ -29,6 +29,13 @@ check_master_manifest() { done } +recover_one() { + # $1 = changeset to recover from + # $2 = destination to recover to + # $3 = private keyfile. Optional unless the changeset is encrypted. + # $4 = password. Optional unless the private key is encrypted. + +} # recover from our backup files. do_final_recover() { # Using files in $1, recover to $2 using optional private key $3 @@ -20,29 +20,10 @@ find_snapshot_loc() { done } -head_convert() { - [[ -f $HEADS/$1 ]] || die "Head $1 does not exist." - [[ -d $HEADS/$1 ]] && die "Head $1 already converted." - local p - mkdir -p "$HEADS/$1.new" - mv "$HEADS/$1" "$HEADS/$1.old" - while read -r line; do - key="${line%%'='*}" - val="${line#*'='}" - [[ $key = $val ]] && continue - printf "%s" "$val" > "$HEADS/$1.new/$key" - done < "$HEADS/$1.old" - mv "$HEADS/$1.new" "$HEADS/$1" - # rm -f "$HEADS.old" -} - head_get() { # $1 = head to get val from # $2 = value to get - [[ -d $HEADS/$1 ]] || head_convert "$1" - if [[ -L $HEADS/$1/$2 ]]; then - readlink "$HEADS/$1/$2" - elif [[ -f $HEADS/$1/$2 ]]; then + if [[ -f $HEADS/$1/$2 ]]; then cat "$HEADS/$1/$2" else return 1 @@ -54,10 +35,7 @@ head_set() { # $1 = head to set value in # $2 = name of value # $3 = value of value - [[ -d $HEADS/$1 ]] || head_convert "$1" - if [[ -d $3 || -f $3 ]]; then - ln -sf "$3" "$HEADS/$1/$2" - elif [[ $3 ]]; then + if [[ $3 ]]; then printf "%s" "$3" > "$HEADS/$1/$2" else rm -f "$HEADS/$1/$2" @@ -105,8 +83,10 @@ update_or_remove_head() { { remove_head "$head"; return 0; } # we want to move to a category that does not have a head. Yay us! - [[ $real_current_cat != $head ]] && \ - { mv "$HEADS/$head" "$HEADS/${real_current_cat}"; head="$real_current_cat"; } + [[ $real_current_cat != $head ]] && { + mv "$HEADS/$head" "$HEADS/${real_current_cat}" + head="$real_current_cat" + } # we do not need to reparent. ttfn [[ $parent = none ]] && return 0 @@ -129,7 +109,8 @@ finalize_remote() { # $1 = directory finalized remote goes into # $2 = string to append to name of manifest file. rm -f "${REMOTE}/${1}/key" - find "${REMOTE}/${1}" -maxdepth 1 -mindepth 1 -type f ! -name 'MANIFEST.*' -printf '%s:%f\n' > "${REMOTE}/${1}/MANIFEST.$2" + find "${REMOTE}/${1}" -maxdepth 1 -mindepth 1 -type f ! -name 'MANIFEST.*' \ + -printf '%s:%f\n' > "${REMOTE}/${1}/MANIFEST.$2" # we need to include the manifest file in the manifest. # Note that the size is not correct -- the restore code will ignore it. echo "0:MANIFEST.$2" >> "$REMOTE/${1}/MANIFEST.${2}" |
