Merge pull request #1254 from ClayRabbit/patch-1

v-backup-user: On-the-fly gzip compression
This commit is contained in:
Serghey Rodin 2017-12-28 15:55:06 +02:00 committed by GitHub
commit 09c884f556
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -229,10 +229,7 @@ if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB" != '*' ]; then
# Backup files
cd $HOMEDIR/$user/web/$domain
tar -cpf $tmpdir/web/$domain/domain_data.tar * ${fargs[@]}
# Compress archive
gzip -$BACKUP_GZIP $tmpdir/web/$domain/domain_data.tar
tar -cpf- * ${fargs[@]} |gzip -$BACKUP_GZIP - > $tmpdir/web/$domain/domain_data.tar.gz
done
# Print total
@ -331,16 +328,14 @@ if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL" != '*' ]; then
# Backup emails
cd $HOMEDIR/$user/mail/$domain_idn
accounts=()
for account in $(ls); do
exclusion=$(echo "$MAIL" |tr ',' '\n' |grep "$domain:")
exclusion=$(echo "$exclusion" |tr ':' '\n' |grep "^$account$")
# Checking exlusions
if [ -z "$exclusion" ] && [[ "$MAIL_SYSTEM" =~ exim ]]; then
echo "$(date "+%F %T") + $account@$domain" |\
tee -a $BACKUP/$user.log
touch $tmpdir/mail/$domain/accounts.tar
tar -rpf $tmpdir/mail/$domain/accounts.tar $account
accounts+=($account)
else
echo "$(date "+%F %T") excluding mail account $account" |\
tee -a $BACKUP/$user.log
@ -348,8 +343,8 @@ if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL" != '*' ]; then
done
# Compress archive
if [ -e "$tmpdir/mail/$domain/accounts.tar" ]; then
gzip -$BACKUP_GZIP $tmpdir/mail/$domain/accounts.tar
if [ ${#accounts[@]} -gt 0 ]; then
tar -cpf- ${accounts[@]} |gzip -$BACKUP_GZIP - > $tmpdir/mail/$domain/accounts.tar.gz
fi
done
@ -469,10 +464,7 @@ if [ "$USER" != '*' ]; then
echo -e "$(date "+%F %T") adding $udir" |tee -a $BACKUP/$user.log
# Backup files and dirs
tar -cpf $tmpdir/user_dir/$udir.tar $udir
# Compress arhive
gzip -$BACKUP_GZIP $tmpdir/user_dir/$udir.tar
tar -cpf- $udir |gzip -$BACKUP_GZIP - > $tmpdir/user_dir/$udir.tar.gz
fi
done
set +f