feat: Ajout d'un script de sauvegarde/restauration pour Traefik

This commit is contained in:
Simon 2020-06-01 09:43:26 +02:00
parent a44047d779
commit da3e1d713b
1 changed files with 41 additions and 0 deletions

41
traefik/run Normal file
View File

@ -0,0 +1,41 @@
#!/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.11.6 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.11.6 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