-
Notifications
You must be signed in to change notification settings - Fork 0
/
jml_dump.bash
42 lines (37 loc) · 1.27 KB
/
jml_dump.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
echo "== $1"
if [[ -f "$1" ]]
then
DB_DETECTED=$(grep "^\$dbs_tiki" "$1" | cut -d"'" -f2| tail -n 1);
USER_DETECTED=$(grep "^\$user_tiki" "$1" | cut -d"'" -f2| tail -n 1);
PASS_DETECTED=$(grep "^\$pass_tiki" "$1" | cut -d"'" -f2| tail -n 1);
else
echo "local.php file not found"
exit 1
fi
if [[ -d "$2" ]]
then
echo "→ $2"
else
echo "backup directory not found"
exit 3
fi
DATE=$(date +"%F_%T")
DUMP="$2/"dump_db_${DB_DETECTED}_${DATE}.sql
DUMPLOG="$2/"dump_last_sql_${DB_DETECTED}.log
echo $DATE
echo $DUMP
read previouslog < $DUMPLOG
echo "previous: " $previouslog
touch $DUMP || exit 2
mysqldump -u "${USER_DETECTED}" --password="${PASS_DETECTED}" -Qqf --skip-extended-insert "${DB_DETECTED}" > $DUMP
echo $DUMP > $DUMPLOG
if [[ -f "$previouslog" ]]
then
echo "Affiche la différence par rapport à $previouslog ? (y/N)"
read affiche
if [ "$affiche" = "y" ]
then
diff $previouslog $DUMP | grep -v 'INSERT INTO `tiki_pages`' | head -n 20
fi
fi