feat: Update backup commands

This commit is contained in:
Simon 2021-01-04 11:23:35 +01:00
parent 0bb2ba32b1
commit c90d9b0f95
6 changed files with 16 additions and 12 deletions

View File

@ -8,7 +8,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
codimd_help() { codimd_help() {
echo "./run backup : Lancement de la sauvegarde de Codimd" echo "./run backup : Lancement de la sauvegarde de Codimd"
echo "./run restore : Restoration de la sauvegarde de Codimd" echo "./run restore : Restauration de la sauvegarde de Codimd"
} }
codimd_backup() { codimd_backup() {

View File

@ -12,8 +12,6 @@ TODO
```sh ```sh
$ ./run $ ./run
./run backup : Lancement de la sauvegarde de Gitea
./run restore : Restoration de la sauvegarde de Gitea
``` ```
## Liens ## Liens

View File

@ -3,12 +3,14 @@
set -eu set -eu
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SERVICE_NAME="Gitea"
. $DIR/../help.sh . $DIR/../help.sh
. $DIR/../postgres/run --only-source . $DIR/../postgres/run --only-source
gitea_help() { gitea_help() {
echo "./run backup : Lancement de la sauvegarde de Gitea" echo "./run backup : Lancement de la sauvegarde de ${SERVICE_NAME}"
echo "./run restore : Restoration de la sauvegarde de Gitea" echo "./run restore : Restauration de la sauvegarde de ${SERVICE_NAME}"
} }
gitea_backup() { gitea_backup() {
@ -17,18 +19,17 @@ gitea_backup() {
BACKUP_DATE=${BACKUP_DATE:-$BACKUP_DATE_DEFAULT} BACKUP_DATE=${BACKUP_DATE:-$BACKUP_DATE_DEFAULT}
backup_folder_create backup_folder_create
POSTGRES_BACKUP_FILE=backups/${BACKUP_DATE}_gitea_postgres.sql POSTGRES_BACKUP_FILE=backups/${BACKUP_DATE}_${GITEA_DOMAIN}_postgres.sql
postgres_backup postgres_backup
docker-compose run --rm -v $GITEA_VOLUME_NAME:/data -v $HOME/backups/gitea:/backup gitea tar cvf /backup/${BACKUP_DATE}_gitea_data.tar /data docker-compose run --rm -v $GITEA_VOLUME_NAME:/data -v $HOME/backups/gitea:/backup gitea tar cvf /backup/${BACKUP_DATE}_${GITEA_DOMAIN}_data.tar /data
} }
gitea_restore() { gitea_restore() {
script_start
script_env script_env
echo "🏁 Start restore PostgreSQL database '$POSTGRES_DB' from '$POSTGRES_BACKUP_FILE'"
cat $POSTGRES_BACKUP_FILE | docker exec -i $POSTGRES_CONTAINER_NAME psql -U $POSTGRES_USER -d $POSTGRES_DB postgres_restore
script_end docker-compose run --rm -v $GITEA_VOLUME_NAME:/data -v $HOME/backups/gitea:/backup gitea tar xvf /backup/${BACKUP_DATE}_${GITEA_DOMAIN}_data.tar /data --strip 1
} }
if [ $# -ge 1 ]; then if [ $# -ge 1 ]; then

View File

@ -26,6 +26,7 @@ docker-compose exec --user www-data nextcloud php occ db:add-missing-primary-key
- [x] crontab https://docs.nextcloud.com//server/latest/admin_manual/configuration_server/background_jobs_configuration.html#cron - [x] crontab https://docs.nextcloud.com//server/latest/admin_manual/configuration_server/background_jobs_configuration.html#cron
- [x] Ajouter un redis : https://www.it-connect.fr/nextcloud-activer-et-configurer-le-cache-redis/ - [x] Ajouter un redis : https://www.it-connect.fr/nextcloud-activer-et-configurer-le-cache-redis/
- [ ] Ajout des informations SMTP - [ ] Ajout des informations SMTP
- [ ] Prendre les bonnes pratique sur https://github.com/crazy-max/docker-nextcloud/blob/master/examples/traefik/docker-compose.yml
[github]: https://github.com/nextcloud/server [github]: https://github.com/nextcloud/server
[documentation]: https://docs.nextcloud.com/server/latest/admin_manual/contents.html [documentation]: https://docs.nextcloud.com/server/latest/admin_manual/contents.html

View File

@ -44,6 +44,9 @@ services:
traefik.docker.network: ${TRAEFIK_NETWORK_NAME} traefik.docker.network: ${TRAEFIK_NETWORK_NAME}
traefik.http.routers.nextcloud.rule: 'Host(`${NEXTCLOUD_DOMAIN}`)' traefik.http.routers.nextcloud.rule: 'Host(`${NEXTCLOUD_DOMAIN}`)'
traefik.http.routers.nextcloud.entrypoints: 'web' traefik.http.routers.nextcloud.entrypoints: 'web'
traefik.http.routers.nextcloud.middlewares: nextcloud_redirect
traefik.http.middlewares.nextcloud_redirect.redirectregex.regex: /.well-known/(card|cal)dav
traefik.http.middlewares.nextcloud_redirect.redirectregex.replacement: /remote.php/dav/
nextcloud-postgres: nextcloud-postgres:
container_name: ${POSTGRES_CONTAINER_NAME} container_name: ${POSTGRES_CONTAINER_NAME}

View File

@ -8,7 +8,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
nextcloud_help() { nextcloud_help() {
echo "./run backup : Lancement de la sauvegarde de Nextcloud" echo "./run backup : Lancement de la sauvegarde de Nextcloud"
echo "./run restore : Restoration de la sauvegarde de Nextcloud" echo "./run restore : Restauration de la sauvegarde de Nextcloud"
} }
nextcloud_backup() { nextcloud_backup() {
@ -18,6 +18,7 @@ nextcloud_backup() {
backup_folder_create backup_folder_create
POSTGRES_BACKUP_FILE=backups/${BACKUP_DATE}_${NEXTCLOUD_DOMAIN}_postgres.sql POSTGRES_BACKUP_FILE=backups/${BACKUP_DATE}_${NEXTCLOUD_DOMAIN}_postgres.sql
docker-compose exec --user www-data nextcloud php occ maintenance:mode --on
postgres_backup postgres_backup
docker run -it --rm -v $HOME/backups/${NEXTCLOUD_DOMAIN}:/backup --volumes-from nextcloud alpine:3.12.2 ash -c "cd /var/www/html && tar cvf /backup/${BACKUP_DATE}_${NEXTCLOUD_DOMAIN}_files.tar ." docker run -it --rm -v $HOME/backups/${NEXTCLOUD_DOMAIN}:/backup --volumes-from nextcloud alpine:3.12.2 ash -c "cd /var/www/html && tar cvf /backup/${BACKUP_DATE}_${NEXTCLOUD_DOMAIN}_files.tar ."