services/traefik_lb/run

42 lines
1.1 KiB
Bash

#!/bin/bash
set -eu
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. $DIR/../help.sh
traefik_help() {
echo "./run backup : Lancement de la sauvegarde de Traefik"
echo "./run restore : Restauration de la sauvegarde de Traefik"
}
traefik_backup() {
script_env
BACKUP_DATE_DEFAULT=`date +%Y%m%d_%H%M%S`
BACKUP_DATE=${BACKUP_DATE:-$BACKUP_DATE_DEFAULT}
backup_folder_create
docker run -it --rm -v $HOME/backups/${TRAEFIK_DOMAIN}:/backup --volumes-from traefik alpine:3.12.3 ash -c "cd /traefik && tar cvf /backup/${BACKUP_DATE}_${TRAEFIK_DOMAIN}_config.tar ."
}
traefik_restore() {
script_env
docker run -it --rm -v $HOME/backups/${TRAEFIK_DOMAIN}:/backup --volumes-from traefik alpine:3.12.3 ash -c "cd /traefik && tar xvf /backup/${BACKUP_DATE}_${TRAEFIK_DOMAIN}_config.tar --strip 1"
}
if [ $# -ge 1 ]; then
if [ "${1}" == "backup" ]; then
script_start
traefik_backup
script_end
elif [ "${1}" == "restore" ]; then
script_start
traefik_restore
script_end
elif [ "${1}" != "--only-source" ]; then
traefik_help
fi
else
traefik_help
fi