You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# backup all tracked files
|
|
|
|
#
|
|
|
|
# @params
|
|
|
|
# Globals
|
|
|
|
# None
|
|
|
|
# Arguments
|
|
|
|
# None
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -f
|
|
|
|
|
|
|
|
mydir="${0%/*}"
|
|
|
|
source "${mydir}"/../helper/set_variable.sh
|
|
|
|
source "${mydir}"/../helper/git_query.sh
|
|
|
|
|
|
|
|
function usage() {
|
|
|
|
echo -e "Usage: dotbare fbackup [-h] ...\n"
|
|
|
|
echo -e "Backup all tracked files to ${DOTBARE_BACKUP}\n"
|
|
|
|
echo -e "optional arguments:"
|
|
|
|
echo -e " -h\t\tshow this help message and exit"
|
|
|
|
}
|
|
|
|
|
|
|
|
[[ ! -d "${DOTBARE_BACKUP}" ]] && mkdir -p "${DOTBARE_BACKUP}"
|
|
|
|
|
|
|
|
cd "${DOTBARE_TREE}"
|
|
|
|
all_files=$(/usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" \
|
|
|
|
ls-files --full-name --directory "${DOTBARE_TREE}")
|
|
|
|
while IFS= read -r line; do
|
|
|
|
dir_name=$(dirname "${line}")
|
|
|
|
[[ ! -d "${DOTBARE_BACKUP}/${dir_name}" ]] && mkdir -p "${DOTBARE_BACKUP}/${dir_name}"
|
|
|
|
cp -v "${line}" "${DOTBARE_BACKUP}/${line}"
|
|
|
|
done <<< "${all_files}"
|