clean hugo install script

master
Kebler Network System Administrator 2021-09-06 10:54:54 -07:00
parent e548e54338
commit a04f0cb2d9
4 changed files with 222 additions and 166 deletions

View File

@ -39,32 +39,55 @@ root_command() {
local server=${args[--server]:-$BACKUP_SERVER}
server=${server:-$s_server}
local host=${args[--host]:-$s_host}
if [[ $host ]]; then host="-H $host"; fi
local hostname=${args[--hostname]:-$s_hostname}
hostname=${hostname:-$s_host}
hostname=${hostname:-$HOSTNAME}
local backup_dir=${args[--backup_dir]:-$BACKUP_DIR}
backup_dir=${backup_dir:-$s_backup_dir}
backup_dir=${backup_dir:-"/backup"}
local smount=${args[--source_mount]:-$BACKUP_SOURCE_MOUNT}
smount=${smount:-$s_source_mount}
echo smount: $smount $s_source_mount
local tmount=${args[--target_mount]:-$BACKUP_TARGET_MOUNT}
tmount=${tmount:-$s_target_mount}
echo tmount: $tmount $s_target_mount
local source="${args[source]:-$s_source}"
source="${source:-$s_source_path}"
source=$(echo "${source:-$PWD}" | tr -s /)
echo yaml source $s_source_path $s_source_mount
echo source $source
echo target $s_target
echo target path $s_target_path
local target=${args[target]:-$s_target}
target="$(echo $target | tr -s /)"
if [[ ${args[--dir]:-$s_dir} ]]; then
target="${target}$(echo $source | tr -s / | sed -e "s#^[.]##")"
fi
if [[ $(isAbsPath $target) ]]; then
echo absolute target directory
target=${target:-$s_target_path}
target=${target:-$(echo "${source}" | tr -s / | sed -e "s#^[.]##")}
target="$(echo "${target}" | tr -s /)"
echo "target> $target"
if [[ ${tmount} ]]; then
target="${tmount}${target}"
else
target="/${s_host:-$HOSTNAME}/${target}"
if [[ $server ]]; then
target="rest:${server}${target}"
else
target=${backup_dir}${target}
fi
target="/${hostname}${target}"
fi
if [[ $server ]]; then
target="rest:${server}${target}"
fi
if [[ $smount ]]; then
setpath="--set-path ${source}"
source=${smount}${source}
fi
local exclude=${args[--exclude_file]:-$BACKUP_EXCLUDE}
exclude=${exclude:-$s_exclude}
@ -95,10 +118,12 @@ root_command() {
# local ssh="--remote-schema \"ssh -C %s /home/sysadmin/.local/bin/rdiff-backup --server\""
#cmd="$sudo rdiff-backup $options $exclude $ssh ${suser}${shost}$source ${tuser}${thost}$target"
local sudo=""
local pcmd="${sudo} ${password} ${bin} -r ${target}"
local cmd="${pcmd} ${host} backup ${source} ${exclude}"
local cmd="${pcmd} -H ${hostname} ${setpath} backup ${source} ${exclude}"
if [[ ${args[--init]} ]]; then cmd="${pcmd} init"; fi
if [[ ${args[--snap]} ]]; then cmd="${pcmd} snapshots"; fi
@ -188,7 +213,7 @@ dbackup_usage() {
# :flag.usage
echo " --view-path PATH"
printf " set custom mount path for viewing of snapshot, --view not required if set\n"
printf " set custom mount point path for viewing of snapshot, --view not required if\n set\n"
echo
# :flag.usage
@ -294,6 +319,11 @@ dbackup_usage() {
echo " BACKUP_DIR"
printf " Backup Directory\n"
echo
# :environment_variable.usage
echo " BACKUP_MOUNT_POINT"
printf " mount point of source if mounted external to host\n"
echo
# :command.usage_examples
printf "Examples:\n"

View File

@ -15,6 +15,8 @@ environment_variables:
help: URL of Restic rest server
- name: BACKUP_DIR
help: Backup Directory
- name: BACKUP_MOUNT_POINT
help: mount point of source if mounted external to host
args:
- name: source
@ -41,7 +43,7 @@ flags:
short: -v
help: mount snapshot for viewing (default is BACKUP_MOUNT or /opt/backup/view)
- long: --view-path
help: set custom mount path for viewing of snapshot, --view not required if set
help: set custom mount point path for viewing of snapshot, --view not required if set
arg: path
- long: --prune
arg: prune

View File

@ -32,32 +32,55 @@ password="RESTIC_PASSWORD=${password}"
local server=${args[--server]:-$BACKUP_SERVER}
server=${server:-$s_server}
local host=${args[--host]:-$s_host}
if [[ $host ]]; then host="-H $host"; fi
local hostname=${args[--hostname]:-$s_hostname}
hostname=${hostname:-$s_host}
hostname=${hostname:-$HOSTNAME}
local backup_dir=${args[--backup_dir]:-$BACKUP_DIR}
backup_dir=${backup_dir:-$s_backup_dir}
backup_dir=${backup_dir:-"/backup"}
local smount=${args[--source_mount]:-$BACKUP_SOURCE_MOUNT}
smount=${smount:-$s_source_mount}
echo smount: $smount $s_source_mount
local tmount=${args[--target_mount]:-$BACKUP_TARGET_MOUNT}
tmount=${tmount:-$s_target_mount}
echo tmount: $tmount $s_target_mount
local source="${args[source]:-$s_source}"
source="${source:-$s_source_path}"
source=$(echo "${source:-$PWD}" | tr -s /)
echo yaml source $s_source_path $s_source_mount
echo source $source
echo target $s_target
echo target path $s_target_path
local target=${args[target]:-$s_target}
target="$(echo $target | tr -s /)"
if [[ ${args[--dir]:-$s_dir} ]]; then
target="${target}$(echo $source | tr -s / | sed -e "s#^[.]##")"
fi
if [[ $(isAbsPath $target) ]]; then
echo absolute target directory
target=${target:-$s_target_path}
target=${target:-$(echo "${source}" | tr -s / | sed -e "s#^[.]##")}
target="$(echo "${target}" | tr -s /)"
echo "target> $target"
if [[ ${tmount} ]]; then
target="${tmount}${target}"
else
target="/${s_host:-$HOSTNAME}/${target}"
if [[ $server ]]; then
target="rest:${server}${target}"
else
target=${backup_dir}${target}
fi
target="/${hostname}${target}"
fi
if [[ $server ]]; then
target="rest:${server}${target}"
fi
if [[ $smount ]]; then
setpath="--set-path ${source}"
source=${smount}${source}
fi
local exclude=${args[--exclude_file]:-$BACKUP_EXCLUDE}
exclude=${exclude:-$s_exclude}
@ -88,10 +111,11 @@ echo exclude: $exclude
# local ssh="--remote-schema \"ssh -C %s /home/sysadmin/.local/bin/rdiff-backup --server\""
#cmd="$sudo rdiff-backup $options $exclude $ssh ${suser}${shost}$source ${tuser}${thost}$target"
local sudo=""
local pcmd="${sudo} ${password} ${bin} -r ${target}"
local cmd="${pcmd} ${host} backup ${source} ${exclude}"
local cmd="${pcmd} -H ${hostname} ${setpath} backup ${source} ${exclude}"
if [[ ${args[--init]} ]]; then cmd="${pcmd} init"; fi
if [[ ${args[--snap]} ]]; then cmd="${pcmd} snapshots"; fi