backup.sh 313 B

123456789101112131415
  1. #!/bin/bash
  2. COPIES=2
  3. BASE=/mnt
  4. echo
  5. date
  6. echo
  7. echo "dumping databases"
  8. i=$(($COPIES - 1))
  9. while [ $i -ge 0 ];
  10. do
  11. [ -s $BASE/databases.sql.$i.gz ] && mv $BASE/databases.sql.$i.gz $BASE/databases.sql.$(($i+1)).gz
  12. i=$(($i-1))
  13. done
  14. /usr/bin/pg_dumpall -U $DB_USERNAME | gzip >$BASE/databases.sql.0.gz