Voila un ptit script pratique pour dumper une db et la compresser ^^
mysqldump.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #!/bin/bash tar_args='-czf' tmpdir='/tmp' mysqldump_args='--user=root --password=password -c' mysqldump $mysqldump_args $1 > $tmpdir/$1.sql if test ! -d $2 then echo 'output dir does not exists'; fi if test -f $tmpdir/$1.sql then tar $tar_args $2/$1.tar.gz $tmpdir/$1.sql && rm $tmpdir/$1.sql fi |
Utilisation
/root/mysqldump.sh wordpress /home/hio/
Explication
Premier argument = nom de la db
Deuxieme argument = Repertoire qui contiendra la db dans un tar.gz
On trouvera donc un wordpress.tar.gz dans /home/hio/
hio@phpoulpe:/home/hio# ls -l /home/hio/wordpress.tar.gz -rw-r--r-- 1 hio hio 78423 mar 3 22:05 /home/hio/wordpress.tar.gz
Simple, pratique et efficace ^^