Compare commits

...

2 Commits

Author SHA1 Message Date
root
9d8748f150 sauvegarde 2023-05-11 22:58:13 +02:00
root
9228d915fb savegarde BDD et scripts 2023-05-11 22:48:11 +02:00
4 changed files with 293 additions and 0 deletions

1
sauvBDD/AP23bis Submodule

@ -0,0 +1 @@
Subproject commit b8711daa5dd4326e2beafedae35174f1ccbad693

253
sauvBDD/backup.sql Executable file

File diff suppressed because one or more lines are too long

24
sauvBDD/restauredb Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
set -e
set -u
save () {
echo "Restauration de la base de données en cours ..."
zcat "${BACKUP_DIR}/catalogue_latest.sql.gz" | ssh root@ap23 "mysql -u admin -padmin ${DB_NAME}"
}
DATE=$(date "+%u")
DB_USER="usersave"
DB_PASS="saveuser"
DB_NAME="catalogue"
BACKUP_DIR="/root/bu"
BACKUP_NAME="${BACKUP_DIR}/${DB_NAME}-${DATE}.sql.gz"
#S'assurer que lutilisateur veuille restaurer la base
read -p "êtes-vous certain de vouloir restaurer la base de données ? (y/n) " answer
if [[ $answer == "y" ]] ; then
save
else
echo "Stop"
fi
exit 0

15
sauvBDD/sauvedb Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
# Variables
set -e
set -u
DATE=$(date "+%u")
DB_USER="usersave"
DB_PASS="saveuser"
DB_NAME="catalogue"
BACKUP_DIR="/root/bu"
BACKUP_NAME="${BACKUP_DIR}/${DB_NAME}-${DATE}.sql.gz"
ssh root@ap23 "mysqldump -u admin -padmin ${DB_NAME}|gzip" > "${BACKUP_NAME}"
cp "${BACKUP_NAME}" "${BACKUP_DIR}/catalogue_latest.sql.gz"