Skip to content

Commit 5eb10ba

Browse files
committed
new and better way to backup - tar without find
1 parent c5ea206 commit 5eb10ba

File tree

2 files changed

+11
-24
lines changed

2 files changed

+11
-24
lines changed

bin/v-backup-user

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -206,36 +206,26 @@ if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB" != '*' ]; then
206206
fi
207207

208208
# Define exclude arguments
209+
exlusion=$(echo -e "$WEB" |tr ',' '\n' |grep "^$domain:")
209210
set -f
210211
fargs=()
211-
fargs+=(-not)
212-
fargs+=(-path)
213-
fargs+=("./logs*")
214-
exlusion=$(echo -e "$WEB" |tr ',' '\n' |grep "^$domain:")
212+
fargs+=(--exclude='logs/*')
215213
if [ ! -z "$exlusion" ]; then
216214
xdirs="$(echo -e "$exlusion" |tr ':' '\n' |grep -v $domain)"
217215
for xpath in $xdirs; do
218-
xpath="$(echo $xpath |sed -e 's/\/*$//' -e 's/^\/*//')"
219-
fargs+=(-not)
220-
fargs+=(-path)
221-
fargs+=("./$xpath/*")
216+
fargs+=(--exclude=$xpath/*)
222217
echo "$(date "+%F %T") excluding directory $xpath"
223218
msg="$msg\n$(date "+%F %T") excluding directory $xpath"
224219
done
225220
fi
221+
set +f
226222

227223
# Backup files
228224
cd $HOMEDIR/$user/web/$domain
229-
find . ${fargs[@]} -type f -or -type l -print0 |\
230-
tar -cpf $tmpdir/web/$domain/domain_data.tar --null -T -
231-
232-
# Backup empty folders
233-
find . ${fargs[@]} -type d -empty -print0 |\
234-
tar -rpf $tmpdir/web/$domain/domain_data.tar --null -T -
225+
tar -cpf $tmpdir/web/$domain/domain_data.tar * ${fargs[@]}
235226

236227
# Compress archive
237228
gzip -$BACKUP_GZIP $tmpdir/web/$domain/domain_data.tar
238-
set +f
239229
done
240230

241231
# Print total
@@ -488,6 +478,7 @@ if [ "$USER" != '*' ]; then
488478
IFS=$'\n'
489479
set -f
490480
i=0
481+
491482
for udir in $(ls -a |egrep -v "conf|web|dns|mail|^\.\.$|^\.$"); do
492483
exclusion=$(echo "$USER" |tr ',' '\n' |grep "^$udir$")
493484
if [ -z "$exclusion" ]; then
@@ -496,13 +487,8 @@ if [ "$USER" != '*' ]; then
496487
echo -e "$(date "+%F %T") adding $udir"
497488
msg="$msg\n$(date "+%F %T") adding $udir"
498489

499-
# Backup files
500-
find ./$udir ${fargs[@]} -type f -or -type l -print0 |\
501-
tar -cpf $tmpdir/user_dir/$udir.tar --null -T -
502-
503-
# Backup empty folders
504-
find ./$udir ${fargs[@]} -type d -empty -print0 |\
505-
tar -rpf $tmpdir/user_dir/$udir.tar --null -T -
490+
# Backup files and dirs
491+
tar -cpf $tmpdir/user_dir/$udir.tar $udir
506492

507493
# Compress arhive
508494
gzip -$BACKUP_GZIP $tmpdir/user_dir/$udir.tar

web/inc/main.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ function _translate() {
102102
$user = $_SESSION['look'];
103103
}
104104

105-
get_favorites();
106-
105+
if (isset($_SESSION['user'])) {
106+
get_favorites();
107+
}
107108

108109
function get_favorites(){
109110
exec (VESTA_CMD."v-list-user-favourites ".$_SESSION['user']." json", $output, $return_var);

0 commit comments

Comments
 (0)