dataset/seed/dovecot/templates/risotto_backup

21 lines
449 B
Bash

#!/bin/bash
BACKUP_DIR="{{ general.backup_dir }}"
mkdir -p $BACKUP_DIR
chown vmail: $BACKUP_DIR
rm -f $BACKUP_DIR/*.done
find /srv/home/ -name *@* -type d -printf "%f\n" | while read user; do
doveadm backup -u $user maildir:$BACKUP_DIR/$user
touch $BACKUP_DIR/$user.done
done
ls $BACKUP_DIR | while read $user; do
if [ ! -f $BACKUP_DIR/$user.done ]; then
rm -rf $BACKUP_DIR/$user
fi
done
rm -f $BACKUP_DIR/*.done
exit 0