savegarde BDD et scripts
This commit is contained in:
parent
b8711daa5d
commit
9228d915fb
253
sauvBDD/backup.sql
Executable file
253
sauvBDD/backup.sql
Executable file
File diff suppressed because one or more lines are too long
24
sauvBDD/restauredb
Executable file
24
sauvBDD/restauredb
Executable 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
15
sauvBDD/sauvedb
Executable 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"
|
Loading…
x
Reference in New Issue
Block a user