backup.sh 384 B

1234567891011121314151617
  1. #!/bin/bash
  2. USER=root
  3. PASS="$(echo $MYSQL_ROOT_PASSWORD)"
  4. COPIES=2
  5. BASE=/mnt
  6. echo
  7. date
  8. echo
  9. echo "dumping databases"
  10. i=$(($COPIES - 1))
  11. while [ $i -ge 0 ];
  12. do
  13. [ -s $BASE/databases.sql.$i.gz ] && mv $BASE/databases.sql.$i.gz $BASE/databases.sql.$(($i+1)).gz
  14. i=$(($i-1))
  15. done
  16. /usr/bin/mysqldump -u $USER --password=$PASS --all-databases | gzip >$BASE/databases.sql.0.gz