Skip to content

Commit 09c884f

Browse files
Merge pull request hestiacp#1254 from ClayRabbit/patch-1
v-backup-user: On-the-fly gzip compression
2 parents 0c05448 + e1d64b8 commit 09c884f

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

bin/v-backup-user

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,7 @@ if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB" != '*' ]; then
229229

230230
# Backup files
231231
cd $HOMEDIR/$user/web/$domain
232-
tar -cpf $tmpdir/web/$domain/domain_data.tar * ${fargs[@]}
233-
234-
# Compress archive
235-
gzip -$BACKUP_GZIP $tmpdir/web/$domain/domain_data.tar
232+
tar -cpf- * ${fargs[@]} |gzip -$BACKUP_GZIP - > $tmpdir/web/$domain/domain_data.tar.gz
236233
done
237234

238235
# Print total
@@ -331,25 +328,23 @@ if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL" != '*' ]; then
331328

332329
# Backup emails
333330
cd $HOMEDIR/$user/mail/$domain_idn
331+
accounts=()
334332
for account in $(ls); do
335333
exclusion=$(echo "$MAIL" |tr ',' '\n' |grep "$domain:")
336334
exclusion=$(echo "$exclusion" |tr ':' '\n' |grep "^$account$")
337335

338336
# Checking exlusions
339337
if [ -z "$exclusion" ] && [[ "$MAIL_SYSTEM" =~ exim ]]; then
340-
echo "$(date "+%F %T") + $account@$domain" |\
341-
tee -a $BACKUP/$user.log
342-
touch $tmpdir/mail/$domain/accounts.tar
343-
tar -rpf $tmpdir/mail/$domain/accounts.tar $account
338+
accounts+=($account)
344339
else
345340
echo "$(date "+%F %T") excluding mail account $account" |\
346341
tee -a $BACKUP/$user.log
347342
fi
348343
done
349344

350345
# Compress archive
351-
if [ -e "$tmpdir/mail/$domain/accounts.tar" ]; then
352-
gzip -$BACKUP_GZIP $tmpdir/mail/$domain/accounts.tar
346+
if [ ${#accounts[@]} -gt 0 ]; then
347+
tar -cpf- ${accounts[@]} |gzip -$BACKUP_GZIP - > $tmpdir/mail/$domain/accounts.tar.gz
353348
fi
354349
done
355350

@@ -469,10 +464,7 @@ if [ "$USER" != '*' ]; then
469464
echo -e "$(date "+%F %T") adding $udir" |tee -a $BACKUP/$user.log
470465

471466
# Backup files and dirs
472-
tar -cpf $tmpdir/user_dir/$udir.tar $udir
473-
474-
# Compress arhive
475-
gzip -$BACKUP_GZIP $tmpdir/user_dir/$udir.tar
467+
tar -cpf- $udir |gzip -$BACKUP_GZIP - > $tmpdir/user_dir/$udir.tar.gz
476468
fi
477469
done
478470
set +f

0 commit comments

Comments
 (0)