parent
383da75532
commit
a5a63a3df2
@ -1,17 +1,32 @@
|
||||
#!/bin/bash
|
||||
source .env
|
||||
|
||||
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"
|
||||
source "$SRC_DIR/.env"
|
||||
|
||||
echo "BACKUP_DIR : $BACKUP_DIR"
|
||||
echo "SRC_DIR : $SRC_DIR"
|
||||
echo "ENVIRONMENT : $ACTUAL_ENV"
|
||||
|
||||
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
|
||||
db_user_file=$(cat ./secrets/db_user.txt)
|
||||
db_password_file=$(cat ./secrets/db_password.txt)
|
||||
db_name_file=$(cat ./secrets/db_name.txt)
|
||||
docker exec -i mysql-maettleship mysqldump -u $db_user_file -p$db_password_file $db_name_file > "$BACKUP_DIR/$TIMESTAMP/$db_name_file.sql"
|
||||
db_password_file=$(cat $SRC_DIR/secrets/db_password.txt)
|
||||
db_name_file=$(cat $SRC_DIR/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"
|
||||
fi
|
||||
|
||||
find "$BACKUP_DIR/" -type d -mtime +7 -exec rm -rf {} \;
|
||||
|
||||
echo " "
|
||||
|
Loading…
Reference in new issue