File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ data/screenshots
1111data /typesense-data
1212# Allow for this director to be created
1313data /uploads /profile-pictures /* .png
14+ data /backups
1415
1516# ## STS ###
1617.apt_generated
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ ORIGIN_PATH=$( pwd)
3+ # Navigate to the script directory
4+ cd $( dirname " $0 " )
5+ if [ $# -eq 0 ]; then
6+ echo " No Env file provided, using default."
7+ . ../.env
8+ else
9+ . $ORIGIN_PATH /$1
10+ fi
11+
12+ mkdir -p ../data/backups
13+
14+ # Variables
15+ BACKUP_DIR=../data/backups
16+ DB_NAME=$POSTGRES_DB
17+ DB_USER=$POSTGRES_USER
18+ DB_PASSWORD=$POSTGRES_PASSWORD
19+ CONTAINER_NAME=findfirst-db-1
20+
21+ # Get current date and time for backup file
22+ TIMESTAMP=$( date +" %F_%T" )
23+ BACKUP_FILE=$BACKUP_DIR /backup_$DB_NAME_$TIMESTAMP .sql
24+
25+ oldBackup=$( ls $BACKUP_DIR /* .sql)
26+
27+ # Run pg_dump inside the PostgreSQL container
28+ docker exec -t $CONTAINER_NAME pg_dump -U $DB_USER $DB_NAME > $BACKUP_FILE
29+
30+ rm $oldBackup
31+
32+ echo " Backup completed: $BACKUP_FILE "
Original file line number Diff line number Diff line change 11#! /bin/sh
22# Intended to be run from the project root directory.
33cd $( dirname " $0 " )
4+ ./backup.sh ../.env
45cd ..
56
67git pull
You can’t perform that action at this time.
0 commit comments