mirror of
https://github.com/myvesta/vesta
synced 2025-08-19 13:01:52 -07:00
new and better way to backup - tar without find
This commit is contained in:
parent
c5ea206e5b
commit
5eb10ba388
2 changed files with 11 additions and 24 deletions
|
@ -206,36 +206,26 @@ if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB" != '*' ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Define exclude arguments
|
# Define exclude arguments
|
||||||
|
exlusion=$(echo -e "$WEB" |tr ',' '\n' |grep "^$domain:")
|
||||||
set -f
|
set -f
|
||||||
fargs=()
|
fargs=()
|
||||||
fargs+=(-not)
|
fargs+=(--exclude='logs/*')
|
||||||
fargs+=(-path)
|
|
||||||
fargs+=("./logs*")
|
|
||||||
exlusion=$(echo -e "$WEB" |tr ',' '\n' |grep "^$domain:")
|
|
||||||
if [ ! -z "$exlusion" ]; then
|
if [ ! -z "$exlusion" ]; then
|
||||||
xdirs="$(echo -e "$exlusion" |tr ':' '\n' |grep -v $domain)"
|
xdirs="$(echo -e "$exlusion" |tr ':' '\n' |grep -v $domain)"
|
||||||
for xpath in $xdirs; do
|
for xpath in $xdirs; do
|
||||||
xpath="$(echo $xpath |sed -e 's/\/*$//' -e 's/^\/*//')"
|
fargs+=(--exclude=$xpath/*)
|
||||||
fargs+=(-not)
|
|
||||||
fargs+=(-path)
|
|
||||||
fargs+=("./$xpath/*")
|
|
||||||
echo "$(date "+%F %T") excluding directory $xpath"
|
echo "$(date "+%F %T") excluding directory $xpath"
|
||||||
msg="$msg\n$(date "+%F %T") excluding directory $xpath"
|
msg="$msg\n$(date "+%F %T") excluding directory $xpath"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
set +f
|
||||||
|
|
||||||
# Backup files
|
# Backup files
|
||||||
cd $HOMEDIR/$user/web/$domain
|
cd $HOMEDIR/$user/web/$domain
|
||||||
find . ${fargs[@]} -type f -or -type l -print0 |\
|
tar -cpf $tmpdir/web/$domain/domain_data.tar * ${fargs[@]}
|
||||||
tar -cpf $tmpdir/web/$domain/domain_data.tar --null -T -
|
|
||||||
|
|
||||||
# Backup empty folders
|
|
||||||
find . ${fargs[@]} -type d -empty -print0 |\
|
|
||||||
tar -rpf $tmpdir/web/$domain/domain_data.tar --null -T -
|
|
||||||
|
|
||||||
# Compress archive
|
# Compress archive
|
||||||
gzip -$BACKUP_GZIP $tmpdir/web/$domain/domain_data.tar
|
gzip -$BACKUP_GZIP $tmpdir/web/$domain/domain_data.tar
|
||||||
set +f
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Print total
|
# Print total
|
||||||
|
@ -488,6 +478,7 @@ if [ "$USER" != '*' ]; then
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
set -f
|
set -f
|
||||||
i=0
|
i=0
|
||||||
|
|
||||||
for udir in $(ls -a |egrep -v "conf|web|dns|mail|^\.\.$|^\.$"); do
|
for udir in $(ls -a |egrep -v "conf|web|dns|mail|^\.\.$|^\.$"); do
|
||||||
exclusion=$(echo "$USER" |tr ',' '\n' |grep "^$udir$")
|
exclusion=$(echo "$USER" |tr ',' '\n' |grep "^$udir$")
|
||||||
if [ -z "$exclusion" ]; then
|
if [ -z "$exclusion" ]; then
|
||||||
|
@ -496,13 +487,8 @@ if [ "$USER" != '*' ]; then
|
||||||
echo -e "$(date "+%F %T") adding $udir"
|
echo -e "$(date "+%F %T") adding $udir"
|
||||||
msg="$msg\n$(date "+%F %T") adding $udir"
|
msg="$msg\n$(date "+%F %T") adding $udir"
|
||||||
|
|
||||||
# Backup files
|
# Backup files and dirs
|
||||||
find ./$udir ${fargs[@]} -type f -or -type l -print0 |\
|
tar -cpf $tmpdir/user_dir/$udir.tar $udir
|
||||||
tar -cpf $tmpdir/user_dir/$udir.tar --null -T -
|
|
||||||
|
|
||||||
# Backup empty folders
|
|
||||||
find ./$udir ${fargs[@]} -type d -empty -print0 |\
|
|
||||||
tar -rpf $tmpdir/user_dir/$udir.tar --null -T -
|
|
||||||
|
|
||||||
# Compress arhive
|
# Compress arhive
|
||||||
gzip -$BACKUP_GZIP $tmpdir/user_dir/$udir.tar
|
gzip -$BACKUP_GZIP $tmpdir/user_dir/$udir.tar
|
||||||
|
|
|
@ -102,8 +102,9 @@ if (isset($_SESSION['look']) && ( $_SESSION['look'] != 'admin' )) {
|
||||||
$user = $_SESSION['look'];
|
$user = $_SESSION['look'];
|
||||||
}
|
}
|
||||||
|
|
||||||
get_favorites();
|
if (isset($_SESSION['user'])) {
|
||||||
|
get_favorites();
|
||||||
|
}
|
||||||
|
|
||||||
function get_favorites(){
|
function get_favorites(){
|
||||||
exec (VESTA_CMD."v-list-user-favourites ".$_SESSION['user']." json", $output, $return_var);
|
exec (VESTA_CMD."v-list-user-favourites ".$_SESSION['user']." json", $output, $return_var);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue