This repository has been archived on 2022-02-20. You can view files and clone it, but cannot push or open issues/pull-requests.
bash-shell-host/all/dev/backup/src/root_command.sh

35 lines
1.1 KiB
Bash

echo Running Backup Command
inspect_args
# module_load ssh
module_load confirm
local source=${args[source]}
local target=${args[target]}
local shost=$([[ ${args[--shost]} ]] && echo ${args[--shost]}::)
local suser=$([[ ${args[--suser]} ]] && echo ${args[--suser]}@)
local thost=$([[ ${args[--host]} ]] && echo ${args[--host]}::)
local tuser=$([[ ${args[--user]} ]] && echo ${args[--user]}@)
local mirror=${args[--mirror]}
local options=$(echo ${args[--options]} | awk '{gsub(/\\/," ")}1')
local sudo=$([[ ${args[--sudo]} ]] && echo sudo)
local exclude=${args[--exclude_file]}
if [[ ! $exclude ]]; then
echo checking local excludes
[[ -f $source/exclude.bac ]] && exclude="$source/exclude.bac"
# ls $source
# [[ $EXCLUDE_BACKUP ]] && exclude="$BACKUP_EXCLUDE"
fi
exclude=$([[ $exclude ]] && echo --exclude-globbing-filelist $exclude)
echo exclude file: $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"
echo $cmd
confirm run this command? || return 1
eval $cmd