25 lines
559 B
Bash
Executable File
25 lines
559 B
Bash
Executable File
#!/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
|