Skip to content
Snippets Groups Projects

Version 2

Merged Hahn Axel (hahn) requested to merge version-2 into master
6 files
+ 748
113
Compare changes
  • Side-by-side
  • Inline

Files

+ 167
0
 
#!/bin/bash
 
# ================================================================================
 
#
 
# TRANSFER :: PLUGIN - TEMPLATE
 
#
 
# this script will be included in ../../transfer.sh
 
#
 
# --------------------------------------------------------------------------------
 
# ah - Axel Hahn <axel.hahn@iml.unibe.ch>
 
# 2021-05-19 ah v0.0 INIT ... WIP
 
# ================================================================================
 
 
# --------------------------------------------------------------------------------
 
# ENV VARS
 
# export variables that are needed by the backup tool
 
# --------------------------------------------------------------------------------
 
 
# export PASSPHRASE
 
 
# --------------------------------------------------------------------------------
 
# INIT
 
# --------------------------------------------------------------------------------
 
 
function t_checkRequirements(){
 
echo "DEBUG: function t_checkRequirements"
 
j_requireUser "root"
 
# j_requireBinary "duplicity"
 
}
 
 
# set variables
 
function t_setVars(){
 
echo "DEBUG: t_setVars"
 
}
 
 
# --------------------------------------------------------------------------------
 
# GENERATE PARAMS :: ALL DIRS
 
# --------------------------------------------------------------------------------
 
 
# return a string with default params
 
# param string param1 of transfer.sh; one of full|inc|auto
 
# param string param2 of transfer.sh; for auto: date i.e. 3M for 3 monthes
 
function t_getParamDefault(){
 
echo "DEBUG: function t_getParamDefault $*"
 
 
# local _method=
 
 
# --- method
 
# test "$1" = "full" && _method="full"
 
# test "$1" = "auto" && _method="--full-if-older-than $2"
 
# echo -n "$_method"
 
 
}
 
 
# return a cli parameter for a single exlude directory
 
# param string cache directory for local index files
 
function t_getParamCacheDir(){
 
if [ ! -z "$1" ]; then
 
local sCacheDir="$1"
 
if [ ! -d $sCacheDir ]; then
 
mkdir -p $sCacheDir
 
chmod 750 $sCacheDir
 
fi
 
echo --archive-dir=$sCacheDir
 
fi
 
}
 
 
# return a cli parameter for a single exlude directory
 
# param string exlude pattern
 
function t_getParamExlude(){
 
# test -z "$1" || echo --exclude-regexp """$*"""
 
}
 
# return a cli parameter for a single exlude directory
 
# param string exlude pattern
 
function t_getParamInlude(){
 
# test -z "$1" || echo --include-regexp """$*"""
 
}
 
 
# return a cli parameter to use an ssh keyfile
 
# param string filename if ssh private key file
 
function t_getParamSshKey(){
 
# test -z "$1" || echo --ssh-options="""-oIdentityFile=$1"""
 
}
 
 
# --------------------------------------------------------------------------------
 
# ACTIONS :: TRANSFER
 
# --------------------------------------------------------------------------------
 
# pre backup actions
 
# uses global vars from ../../transfer.sh
 
function t_cmdPre(){
 
# echo TODO PRE actions before starting transfer
 
}
 
 
 
# post backup actions
 
# uses global vars from ../../transfer.sh
 
function t_cmdPost(){
 
# echo TODO POST actions after all transfers
 
}
 
 
# --------------------------------------------------------------------------------
 
# GENERATE PARAMS :: SINGLE DIR
 
# --------------------------------------------------------------------------------
 
 
# get target url/ directory
 
# param string directory to backup
 
function t_sd_getTarget(){
 
# directory based target
 
j_getFullTarget "$1"
 
# for host based backup target - remove param:
 
# j_getFullTarget ""
 
}
 
 
function t_sd_getCmdBackup(){
 
# echo duplicity ${sBackupParams} ${mydir} ${sTarget}
 
}
 
 
# pre backup actions
 
# uses global vars from ../../transfer.sh
 
function t_sd_cmdPre(){
 
}
 
 
 
# post backup actions
 
# uses global vars from ../../transfer.sh
 
function t_sd_cmdPost(){
 
}
 
 
# --------------------------------------------------------------------------------
 
# VERIFY RETURNCODES
 
# --------------------------------------------------------------------------------
 
 
# init repository
 
function t_rcCheckInit(){
 
case $1 in
 
0) color ok; echo "OK - the repository was created." ;;
 
*) color error; echo "Verify output above - returncode of init was $1" ;;
 
esac
 
color reset
 
}
 
# backup files
 
function t_rcCheckBackup(){
 
case $1 in
 
0) color ok; echo "OK" ;;
 
*) color error; echo "Backup error - returncode was $1" ;;
 
esac
 
color reset
 
}
 
 
# repoitory cleanup
 
function t_rcCheckCleanup(){
 
case $1 in
 
0) color ok; echo "OK" ;;
 
*) color error; echo "Cleanup error - returncode was $1" ;;
 
esac
 
color reset
 
}
 
 
# restore files
 
function t_rcCheckRestore(){
 
case $1 in
 
0) color ok; echo "OK" ;;
 
*) color error; echo "Restore error - returncode was $1" ;;
 
esac
 
color reset
 
}
 
 
# --------------------------------------------------------------------------------
Loading