parent
383da75532
commit
a5a63a3df2
@ -1,17 +1,32 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
source .env
|
|
||||||
|
|
||||||
TIMESTAMP=$(date +"%F")
|
TIMESTAMP=$(date +"%F")
|
||||||
BACKUP_DIR="../maettleship_save"
|
APATH=$(pwd)
|
||||||
|
|
||||||
|
echo "==========LOGS : $TIMESTAMP==========="
|
||||||
|
|
||||||
|
if [ $APATH = "/root" ]; then
|
||||||
|
echo "USING IN ROOT"
|
||||||
|
APATH="$(pwd)/../home/dev"
|
||||||
|
fi
|
||||||
|
|
||||||
|
BACKUP_DIR="$APATH/maettleship_save"
|
||||||
|
SRC_DIR="$APATH/maettleship"
|
||||||
|
|
||||||
mkdir -p "$BACKUP_DIR/$TIMESTAMP"
|
mkdir -p "$BACKUP_DIR/$TIMESTAMP"
|
||||||
|
source "$SRC_DIR/.env"
|
||||||
|
|
||||||
|
echo "BACKUP_DIR : $BACKUP_DIR"
|
||||||
|
echo "SRC_DIR : $SRC_DIR"
|
||||||
|
echo "ENVIRONMENT : $ACTUAL_ENV"
|
||||||
|
|
||||||
if [ $ACTUAL_ENV = 'dev' ]; then
|
if [ $ACTUAL_ENV = 'dev' ]; then
|
||||||
docker exec -i mysql-maettleship mysqldump -u $DB_USER -p$DB_PASSWORD $DB_NAME > "$BACKUP_DIR/$TIMESTAMP/$DB_NAME.sql"
|
docker exec -i maettleship_db_1 mysqldump -u $DB_USER -p$DB_PASSWORD $DB_NAME > "$BACKUP_DIR/$TIMESTAMP/$DB_NAME.sql"
|
||||||
else
|
else
|
||||||
db_user_file=$(cat ./secrets/db_user.txt)
|
db_password_file=$(cat $SRC_DIR/secrets/db_password.txt)
|
||||||
db_password_file=$(cat ./secrets/db_password.txt)
|
db_name_file=$(cat $SRC_DIR/secrets/db_name.txt)
|
||||||
db_name_file=$(cat ./secrets/db_name.txt)
|
docker exec -i maettleship_db_1 mysqldump -u $DB_USER -p$db_password_file $db_name_file > "$BACKUP_DIR/$TIMESTAMP/$db_name_file.sql"
|
||||||
docker exec -i mysql-maettleship mysqldump -u $db_user_file -p$db_password_file $db_name_file > "$BACKUP_DIR/$TIMESTAMP/$db_name_file.sql"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
find "$BACKUP_DIR/" -type d -mtime +7 -exec rm -rf {} \;
|
find "$BACKUP_DIR/" -type d -mtime +7 -exec rm -rf {} \;
|
||||||
|
|
||||||
|
echo " "
|
||||||
|
Loading…
Reference in new issue