Skip to content

Commit

Permalink
Merge pull request #110 from WildCodeSchool/develop
Browse files Browse the repository at this point in the history
added DRP
  • Loading branch information
LuckyShuii authored Feb 1, 2025
2 parents 955af1b + 2128cf3 commit bbaed6f
Show file tree
Hide file tree
Showing 16 changed files with 2,168 additions and 6 deletions.
9 changes: 8 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
JWT_SECRET_KEY=mykey
FRONTEND_URL=myfrontendurl
FRONTEND_URL=myfrontendurl

# db dump variables
CONTAINER_NAME=changeme
DB_USERNAME=changeme
DUMPS_FOLDER=changeme
RCLONE_REMOTE_NAME=changeme
RCLONE_REMOTE_FOLDER=changeme
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ node_modules/
.idea/
.DS_Store
.env
/frontend/package-lock.json
/frontend/package-lock.json
23 changes: 23 additions & 0 deletions DRP_restart_app_process.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Comment redéployer rapidement son application à partir (ou non) de sauvegardes
Comment mettre en place les bonnes pratiques de sauvegarde
Comment vérifier et tester la bonne intégrité des sauvegardes

commande kron à faire sur le serveur utilisé :
crontab -e
y ajouter : * 5 * * * sh /home/wns_student/dump.sh

fichier à exécuter pour générer un dump sql (!avoir le container de la db qui tourne!) : ./db/generate_dump.sh
Date et objectifs du document

27/01/2025
This document purpose is to help restore & restart the application with the latest DB dump in case of a crash.

Application architecture:

Contraintes techniques et infrastructure nécessaire:

Notice de mise en place des routines de sauvegarde et de leur vérification:

Notice de restauration pour démarrer depuis une sauvegarde:

Mettre le dernier fichier dump.sql dans le dossier /db/dump et démarrer le script à la racine du projet 'restore_app.sh'
1 change: 1 addition & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FROM node:lts-alpine3.18
WORKDIR /app

RUN apk --no-cache add curl
RUN apk add --no-cache rclone

COPY package.json package.json
RUN npm install loglevel --verbose
Expand Down
1 change: 1 addition & 0 deletions db/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM postgres:16
24 changes: 24 additions & 0 deletions db/check_dumps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This script simply removes dump files older than 7 days

import os
import time

DUMPS_FOLDER = os.path.join(os.getcwd(), "dumps")

DAYS_TO_KEEP = 7

now = time.time()
limit_time = now - (DAYS_TO_KEEP * 86400)

for filename in os.listdir(DUMPS_FOLDER):
file_path = os.path.join(DUMPS_FOLDER, filename)

if os.path.isfile(file_path):

file_modified_time = os.path.getmtime(file_path)

if file_modified_time < limit_time:
print(f"Deleting {file_path}...")
os.remove(file_path)

print("Cleaning done...")
Loading

0 comments on commit bbaed6f

Please sign in to comment.