salut,
j'utilise un script shell pour faire une sauvegarde hebdomadaire de mes bases de donnees.
1 2 3 4 5 6 7 8 9 10 11 12 13
| #!/bin/sh
USER=*******
PASS=*******
DESTINATION=/var/backups
DATE='date +%Y-%m-%d'
WEEK='date +%W'
let "DEL=$WEEK-4"
mysqldump -u $USER --password=$PASS bioinformatics | gzip > $DESTINATION/bioinformatics.$WEEK.$DATE.sql.gz
rm -rf $DESTINATION/$DEL.*.sql.gz |
ce script se lance grace a un cron tous les samedis à 3 h du mat:
0 3 * * 6 /usr/local/bin/backup_database
mais voici le nom de mon fichier :
1 2 3
| root@STRI-DB01:/var/backups# ls -l
total 1036
-rw-r--r-- 1 root root 20 Oct 14 03:00 bioinformatics.date +%W.date +%Y-%m-%d.sql.gz |
c'est pas tout a fait ce que je voulais et comme je suis pas un pro du shell
, j'aurai besoin d'un petit coup de main !
Partager