services/hedgedoc/run

48 lines
1.3 KiB
Plaintext
Raw Permalink Normal View History

2021-07-21 11:07:36 +02:00
#!/bin/bash
set -eu
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. $DIR/../help.sh
. $DIR/../postgres/run --only-source
hedgedoc_help() {
echo "./run backup : Lancement de la sauvegarde de HedgeDoc"
echo "./run restore : Restauration de la sauvegarde de HedgeDoc"
}
hedgedoc_backup() {
script_env
BACKUP_DATE_DEFAULT=`date +%Y%m%d_%H%M%S`
BACKUP_DATE=${BACKUP_DATE:-$BACKUP_DATE_DEFAULT}
backup_folder_create
POSTGRES_BACKUP_FILE=backups/${BACKUP_DATE}_${HEDGEDOC_DOMAIN}_postgres.sql
postgres_backup
docker run -it --rm -v $HOME/backups/${HEDGEDOC_DOMAIN}:/backup --volumes-from ${HEDGEDOC_CONTAINER_NAME} alpine:3.12.3 ash -c "cd config && tar cvf /backup/${BACKUP_DATE}_${HEDGEDOC_DOMAIN}_config.tar ."
2021-07-21 11:07:36 +02:00
}
hedgedoc_restore() {
script_env
postgres_restore
docker run -it --rm -v $HOME/backups/${HEDGEDOC_DOMAIN}:/backup --volumes-from ${HEDGEDOC_CONTAINER_NAME} alpine:3.12.3 ash -c "cd /config && tar xvf /backup/${BACKUP_DATE}_${HEDGEDOC_DOMAIN}_config.tar --strip 1"
2021-07-21 11:07:36 +02:00
}
if [ $# -ge 1 ]; then
if [ "${1}" == "backup" ]; then
script_start
hedgedoc_backup
script_end
elif [ "${1}" == "restore" ]; then
script_start
hedgedoc_restore
script_end
elif [ "${1}" != "--only-source" ]; then
hedgedoc_help
fi
else
hedgedoc_help
fi