cloud-apache-container/scripts/mysql-backup.sh

14 lines
335 B
Bash
Raw Normal View History

2024-10-14 19:15:11 +00:00
#!/usr/bin/env bash
user=$1
mysql_db=$2
dt=$(date +%y%m%d-%T)
if [ ! -d /home/$user/_db_backups ]; then
mkdir -p /home/$user/_db_backups
fi
/usr/bin/mysqldump $mysql_db > /home/$user/_db_backups/$mysql_db.$dt.sql
chown -R $user:$user /home/$user/_db_backups
/usr/bin/find /home/$user/_db_backups/ -type f -mmin +360 -delete
2024-10-14 19:15:11 +00:00
exit 0