forked from Alenheim/Aion-Lightning-4.9
-
Notifications
You must be signed in to change notification settings - Fork 1
/
backup.sh
executable file
·44 lines (35 loc) · 952 Bytes
/
backup.sh
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
43
44
#!/bin/sh
CONTAINER_NAME=$1
DB_PASSWORD="my_root_password"
if [ -z $CONTAINER_NAME ]
then
CONTAINER_NAME="aion49-database"
fi
BKP_FOLDER="./DB_Backups"
if [ ! -d $BKP_FOLDER ]
then
mkdir $BKP_FOLDER
fi
DATE_FOLDER="$BKP_FOLDER/$(date +%Y-%m-%d_%H-%M-%S)"
if [ ! -d $DATE_FOLDER ]
then
mkdir $DATE_FOLDER
fi
for DATABASE_NAME in al_server_gs al_server_ls
do
EXPORT_FILE="$DATE_FOLDER/$DATABASE_NAME.sql"
echo ""
echo "---------------------------------------------------"
echo ""
echo "Backing up database '$DATABASE_NAME' from container '$CONTAINER_NAME'..."
docker exec -e MYSQL_PWD="$DB_PASSWORD" $CONTAINER_NAME /usr/bin/mysqldump -u root $DATABASE_NAME > $EXPORT_FILE
echo "Exporting $DATABASE_NAME.sql file from container..."
echo "Backed up database '$DATABASE_NAME' to $EXPORT_FILE"
done
echo ""
echo "---------------------------------------------------"
echo ""
echo "Done!"
echo ""
echo -n "Press [ENTER] to finish"
read exitvar