Voici le script... commentaires bienvenus.
Et bien-sûr, vous l'utilisez à vos risques et périls.
#! /bin/sh
#set -x
user=votre_user
password=votre_mdp
rm -f curl.headers
rm -f backup.php
curl -s -S -O -D curl.headers -d "login=$user&password=$password&check=1&all=1" http://sql.free.fr/backup.php
if [ $? -ne 0 ]
then
echo "Erreur curl" >&2
exit 1
else
echo "Backup MySQL for $user OK"
fi
grep -q "HTTP/1.1 200 OK" curl.headers
if [ $? -eq 0 ]
then
grep -q "Content-Disposition: attachment" curl.headers
if [ $? -eq 0 ]
then
filename=$(grep "Content-Disposition: attachment" curl.headers | sed -e 's/.*filename="//' | sed -e 's/";.*$//')
mv backup.php backup_mysql_$filename
echo "Saved in backup_mysql_$filename"
fi
ls -1 backup_mysql_*.gz | sort -u | head -n-10 | xargs -r rm -v
else
echo -n "Error : " >&2
grep "HTTP/1.1 " curl.headers >&2
exit 1
fi
5 réactions
1 De pingouin furtif - 24/06/2007, 21:38
Merci, pile poil ce que je cherchais :)
2 De Tanelorn - 08/09/2007, 22:56
J'étais parti dans la même direction mais butais sur la récupération du nom de fichier. Merci d'avoir rendu ce script public !
3 De Christophe - 10/12/2009, 15:37
Nickel, merci ! (+)
4 De mobidyc - 22/11/2010, 12:57
un grand merci ! ;)
5 De Minimoi - 10/03/2011, 17:41
Et voila, inutile de réinventer la roue.
En grand merci pour toi, c'est aussi ce qu'il me fallait.
:)
@++