Code : Tout sélectionner
sudo nano backup_script.sh
Code: Select all
#!/bin/bash
USER="user_name"
PASSWORD="password"
OUTPUT="/srv/votre_dir"
rm "$OUTPUT/*gz" > /dev/null 2>&1
databases=`mysql --user=$USER --password=$PASSWORD -e "SHOW DATABASES;" | tr -d$
for db in $databases; do
if [[ "$db" != "information_schema" ]] && [[ "$db" != _* ]] ; then
echo "Dumping database: $db"
mysqldump --force --opt --routines --user=$USER --password=$PASSWORD --$
gzip $OUTPUT/`date +%Y%m%d`.$db.sql
fi
done
Code : Tout sélectionner
sudo chmod 777 backup_script.sh