. lib/get_passphrase
. lib/path_tmp_timestamped
+PATH_BORG_CONF_SECURITY="${PATH_BORG_CONF}/security"
+
BIN_NAME="$(basename $0)"
CMD_HELP=help
CMD_KEYS=keys
echo "Wrapper around certain borgbackup usages.\n"
echo "Available commands:\n"
echo " ${CMD_HELP} print this help and exit"
- echo " ${CMD_KEYS} list known repo keys by ID and filename"
+ echo " ${CMD_KEYS} list known repos in ID, key filename, and alleged location"
echo " ${CMD_ORGPULL} pull most recent org directory available in repos"
}
fi
}
+_path_repo_location() {
+ echo "${PATH_BORG_CONF_SECURITY}/${1}/location"
+}
+
cmd_keys() {
_PATH_CONF_KEYS="${PATH_BORG_CONF}/keys"
echo "Known keys (from ${PATH_BORG_CONF}):"
ls -1 "${_PATH_CONF_KEYS}" | while read _FILENAME; do
_KEY_ID=$(head -1 "${_PATH_CONF_KEYS}/${_FILENAME}" | cut -d' ' -f2)
- echo "${_KEY_ID} ${_FILENAME}"
+ _LOCATION=?
+ _PATH_LOC="$(cat $(_path_repo_location ${_KEY_ID}))"
+ if [ -f "${_PATH_LOC}" ]; then
+ _LOCATION="$(cat ${_PATH_LOC})"
+ fi
+ echo "${_KEY_ID} ${_FILENAME} ${_LOCATION}"
done
}
cmd_orgpull() {
- _PATH_CONF_SECURITY="${PATH_BORG_CONF}/security"
- _NAME_REPO=borg
_NAME_ARCHIVE=orgdir
- # determine server
+ # determine server and repo
_PATH_PIPE="$(path_tmp_timestamped 'pipe')"
mkfifo "${_PATH_PIPE}"
- ls -1 "${_PATH_CONF_SECURITY}/" > "${_PATH_PIPE}" &
+ ls -1 "${_PATH_BORG_CONF_SECURITY}/" > "${_PATH_PIPE}" &
while read _FILENAME; do
- _PATH_LOC="${_PATH_CONF_SECURITY}/${_FILENAME}/location"
- _NAME_SERVER="$(cat ${_PATH_LOC} | cut -d'/' -f3)"
+ _REPO="$(cat $(_path_repo_location ${_FILENAME}))"
+ _NAME_SERVER="$(echo ${_REPO} | cut -d'/' -f3)"
if ping -c1 -W2 "${_NAME_SERVER}" > /dev/null 2>&1; then
break
else
rm "${_PATH_PIPE}"
# determine passphrase and archive
- _REPO="${_NAME_SERVER}:${_NAME_REPO}"
echo "Checking out ${_REPO} …"
while true; do
if [ -z "${BORG_PASSPHRASE}" ]; then