2020-06-01 09:43:26 +02:00
|
|
|
#!/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
|
|
|
|
|
2021-01-04 11:30:02 +01:00
|
|
|
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 ."
|
2020-06-01 09:43:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
traefik_restore() {
|
|
|
|
script_env
|
2021-01-04 11:30:02 +01:00
|
|
|
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"
|
2020-06-01 09:43:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|