#!/bin/bash -eux

export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin

echo BEGIN > /tmp/dump-logs
date > /tmp/dump-logs

for domain in `ls /data/domains`; do
  echo $domain >> /tmp/dump-logs
  cd /data/domains/${domain}/
  if [[ -f ./scripts/pre-backup ]]; then
    cat ./scripts/pre-backup >> /tmp/dump-logs
    ./scripts/pre-backup >> /tmp/dump-logs
  fi
done

date > /tmp/dump
echo END >> /tmp/dump-logs
date >> /tmp/dump-logs
