enviroCar / architecture

Docker Architecture for envirocar.org
GNU Affero General Public License v3.0
1 stars 0 forks source link

enviroCar Migration #1

Closed autermann closed 2 years ago

autermann commented 5 years ago
autermann commented 5 years ago
ssh envirocar.org mongodump --db=enviroCar --archive | docker exec mongo-stable mongorestore --archive

Takes around 75 minutes.

autermann commented 5 years ago
#!/bin/bash

set -e

DIRECTORY=/backup/preliminary/docker/mongodb
LABEL=org.envirocar.backup.mongodb

mkdir -p "${DIRECTORY}"

docker ps --format "{{.ID}} {{.Names}} {{.Label \"${LABEL}\"}}" --filter "label=${LABEL}" | 
while read id name database; do
  echo "[$(date)] Dumping Mongo database ${database} of ${id} to ${name}.gz" >&2
  docker exec ${id} mongodump --db  ${database} --gzip --archive >  "${DIRECTORY}/${name}.gz"
done 
autermann commented 5 years ago
#!/bin/bash
set -e

DIRECTORY=/backup/preliminary/docker/volumes
LABEL='org.envirocar.backup'

mkdir -p "${DIRECTORY}"

docker volume ls -f "LABEL=${LABEL}=true" -f 'driver=local' --format '{{.Name}} {{.Mountpoint}}' | 
  while read volume mount; do 
    echo "[$(date)] Backing up Volume: ${volume}" >&2

    containers=$(docker ps --format '{{.Names}}' --filter "volume=${volume}")
    if [ ${#containers} -gt 0 ]; then
      echo "[$(date)] Pausing containers: ${containers[@]}" >&2
      docker pause ${containers[@]}
    fi

    rsync "${mount}" "${DIRECTORY}/${volume}"

    if [ ${#containers} -gt 0 ]; then
      echo "[$(date)] Unpausing containers: ${containers[@]}" >&2
      docker unpause ${containers[@]}
    fi
  done
EHJ-52n commented 5 years ago

@autermann Ist der Punkt

  • [ ] (Weiterleitung an neuen Server) @EHJ-52n

noch notwendig?

autermann commented 5 years ago

Nein

autermann commented 5 years ago
#!/bin/bash

set -e

DIRECTORY=/backup/preliminary/docker/postgres
LABEL=org.envirocar.backup.postgres

mkdir -p "${DIRECTORY}"

docker ps --format "{{.ID}} {{.Names}} {{.Label \"${LABEL}\"}}" --filter "label=${LABEL}" | 
while read id name label; do
  IFS=',' read -ra tables <<<"${label}"
  for table in ${tables[@]}; do 
    filename="${DIRECTORY}/${name}_${table}.gz"
    echo "[$(date)] Dumping Postgres table ${table} of ${name} to ${filename}" >&2
    [ -e "${filename}" ] && rm "${filename}"
    docker exec ${id} sh -c "PGPASSWORD=\"\${POSTGRES_PASSWORD}\" pg_dump -d "\${POSTGRES_DB}" -U "\${POSTGRES_USER}" -E UTF-8 -F plain -t ${table} ${database}" | gzip > "${filename}"
  done
done 
EHJ-52n commented 4 years ago

Das Backup-Konzept ist implementiert und muss nächste Woche bezügl. Speicherverbrauch verifiziert werden, damit uns über die Weihnachtsfeiertage nicht die Festplatten voll laufen.

autermann commented 4 years ago

GeoEvent Server überprüfen und deaktivieren (ags.52north.org)

@EHJ-52n wie sieht es damit aus?