diff --git a/services/pg-backup/Makefile b/services/pg-backup/Makefile deleted file mode 100644 index 81ef1f8e7..000000000 --- a/services/pg-backup/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -.DEFAULT_GOAL := help - -REPO_BASE_DIR := $(shell git rev-parse --show-toplevel) - -# TARGETS -------------------------------------------------- -include ${REPO_BASE_DIR}/scripts/common.Makefile -include $(REPO_CONFIG_LOCATION) - -# Internal VARIABLES ------------------------------------------------ -# STACK_NAME defaults to name of the current directory. Should not to be changed if you follow GitOps operating procedures. -STACK_NAME = $(notdir $(shell pwd)) -TEMP_COMPOSE=.stack.${STACK_NAME}.yaml - -.PHONY: up ## Deploys pg-backup stack -up: .init .env ${TEMP_COMPOSE} ## Deploys pg-backup stack - docker stack deploy --with-registry-auth --compose-file ${TEMP_COMPOSE} ${STACK_NAME} - -.PHONY: up-dalco ## Deploys pg-backup stack for Dalco Cluster -up-dalco: up - -.PHONY: up-local ## Deploys pg-backup stack for local deployment -up-local: up - -.PHONY: up-master ## Deploys pg-backup stack for Master Cluster -up-master: up-dalco - -.PHONY: up-public ## Deploys pg-backup stack for public access cluster -up-public: up - -# Helpers ------------------------------------------------- - -.PHONY: ${TEMP_COMPOSE} -${TEMP_COMPOSE}: docker-compose.yml venv .env - ${REPO_BASE_DIR}/scripts/docker-stack-config.bash -e .env $< > $@ diff --git a/services/pg-backup/README.md b/services/pg-backup/README.md deleted file mode 100644 index 761551163..000000000 --- a/services/pg-backup/README.md +++ /dev/null @@ -1,52 +0,0 @@ -# PG Backup - -- PG backup service do a backup every day at 11pm of simcore PGSQL database in a distant server. -- The backup is done in plain PGSQL format - - -## Important notes -- Unlike the older system, each simcore stack need his own pg-backup service to be started. E.G for dalco-staging, and dalco production, two pg-backup need to be started, each in the corresponding /deployment/production and /deployment/staging folders. -- PG-backup service needs to be started after simcore-postgres. Otherwise it will fail but the container will stay in a running state (this is caught by e2e-ops) - -## Restore backup - -- Check that the backup exists -- Stop PGSQL (you can stop simcore) -- Delete pgsql volume (STACK_postgres_data) -``` -docker volume rm _postgres_data -``` -- Start PGSQL (simcore stack) -- Copy the backup into the container. If the id of the container starts with a5a : -``` -docker cp PG_osparc-master.speag.com_simcoredb.05-March-2023.dmp a5a:/ -``` -- Inside of the container, execute this command -``` -createuser -s postgres -U scu -``` -- Stop all connections to the current empty database : -1) Connect to psql in sudo mode : -``` -su postgres -psql -``` -2) Execute a query that will stop all the connections -``` -SELECT - pg_terminate_backend(pg_stat_activity.pid) -FROM - pg_stat_activity -WHERE - pg_stat_activity.datname = 'simcoredb' - AND pid <> pg_backend_pid(); -``` -- Delete simcore database -``` -DROP DATABASE simcoredb; -quit -``` -- Finally, restore the DB : -``` -psql simcoredb < /PG_osparc-master.speag.com_simcoredb.05-March-2023.dmp -``` diff --git a/services/pg-backup/docker-compose.yml b/services/pg-backup/docker-compose.yml deleted file mode 100644 index 21356d4bb..000000000 --- a/services/pg-backup/docker-compose.yml +++ /dev/null @@ -1,32 +0,0 @@ -version: '3.7' -services: - pg_backup: - image: kartoza/pg-backup:14-3.3@sha256:4d1867707b1da879324199fb3c0d542122113bfc50cd2418764efb8f4309d6c1 - volumes: - - /backups:/backups - environment: - - DUMPPREFIX=PG_${MACHINE_FQDN} - - DUMP_ARGS="--format=plain" - - POSTGRES_HOST=${PREFIX_STACK_NAME}_postgres - - POSTGRES_USER=${POSTGRES_USER} - - POSTGRES_PASS=${POSTGRES_PASSWORD} - - POSTGRES_PORT=${POSTGRES_PORT} - - REMOVE_BEFORE=30 - # - RUN_ONCE=true # By default every day at 11pm - networks: - - public - deploy: - placement: - constraints: - - node.labels.pgbackup==true - resources: - limits: - memory: 512M - cpus: "0.5" - reservations: - memory: 64M - cpus: "0.1" -networks: - public: - name: ${PUBLIC_NETWORK} - external: true diff --git a/services/pg-backup/template.env b/services/pg-backup/template.env deleted file mode 100644 index 1a1e6b854..000000000 --- a/services/pg-backup/template.env +++ /dev/null @@ -1,7 +0,0 @@ -MACHINE_FQDN=${MACHINE_FQDN} -POSTGRES_USER=${POSTGRES_USER} -POSTGRES_PASSWORD=${POSTGRES_PASSWORD} -POSTGRES_PORT=${POSTGRES_PORT} -PREFIX_STACK_NAME=${PREFIX_STACK_NAME} -PUBLIC_NETWORK=${PUBLIC_NETWORK} -MONITORED_NETWORK=${MONITORED_NETWORK}