Situatie
Solutie
Pasi de urmat
pico backup.sh
introducem urmatoarul script :
#!/bin/bash
USER=”utilizator”
PASSWORD=”parola”
OUTPUT=”locatie unde sa salveze”
rm “$OUTPUT/*gz” > /dev/null 2>&1
databases=`mysql –user=$USER –password=$PASSWORD -e “SHOW DATABASES;” | tr -d “| ” | grep -v Database`
for db in $databases; do
if [[ “$db” != “information_schema” ]] && [[ “$db” != _* ]] ; then
echo “Dumping database: $db”
mysqldump –force –opt –user=$USER –password=$PASSWORD –databases $db > $OUTPUT/`date +%Y%m%d`.$db.sql
gzip $OUTPUT/`date +%Y%m%d`.$db.sql
fi
done
salvam scriptul , dupa salvarea scriptului trebuie sa punem scriptul in crontab :
chmod +x backup.sh
00 20 * * * /locatie/script/backup.sh
Scriptul va rula in fiecare zi la ora 20:00
Leave A Comment?