Answer the question
In order to leave comments, you need to log in
How to exclude full path from tar?
Like in this script
#!/bin/bash
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
#date=$(date +%d-%m-%Y_%H-%M-%S)
#mbg="moscow-battle.ru_"
#tar -cjpf /user/backup_srv/sites/$mbg"$date".tar.bz2 --exclude-from=/user/backup_srv/filters/filter-list_sites.txt --absolute-names /var/www/moscow-battle.ru
filter="/user/backup_srv/filters/filter-list_sites.txt"
date=$(date +%d-%m-%Y_%H-%M-%S)
sites="/var/www"
mvsource="/user/backup_srv/sites/sites_$date.tar.bz2"
mvdest="gdrive:/backup_sites/$date.tar.bz2"
tar -cjpf /user/backup_srv/sites/sites_"$date".tar.bz2 --exclude $sites/demo.moscow-battle.ru --exclude $sites/fastdl.moscow-battle.ru --exclude-from=$filter --absolute-names $sites
rclone moveto "$mvsource" "$mvdest"
#find moscow-battle.ru -type f -size -50M -print0 | tar -cjpf /user/back up_srv/sites/$mbg.tar.bz2 --null -T -
Answer the question
In order to leave comments, you need to log in
change the current directory before launch tar
and tweak the arguments:
oldpwd=`pwd`
cd $sites ;
tar -cjf /user/backup_srv/sites/sites_"$date".tar.bz2 --exclude demo.moscow-battle.ru --exclude fastdl.moscow-battle.ru --exclude-from=$filter .
cd $oldpwd
Write what exactly you want to do, not the problem itself, but the action. perhaps there are already ready-made scripts.
here atk exclusions are made.
tar -cvpzf $TMPDIR/$DATEYM/$ELEMENT-$DATE.tar.gz --directory $SITEDIR/$ELEMENT/$WEB --ignore-failed-read --exclude='./bitrix/tmp' --exclude='./bitrix/updates' --exclude='./bitrix/backup/*\.gz*' --exclude='./bitrix/backup/*\.tar*' --exclude='./bitrix/cache' --exclude='./bitrix/managed_cache' --exclude='./bitrix/stack_cache' --exclude='./upload/resize_cache' --exclude='./stats' . >> /dev/nool 2> /var/log/backup_error.log
There are some terrible crutches in the comments to the question :)
The author, apparently you used -C incorrectly . An example of how it works with an explanation: How to fix this script? -C solves the problem directly:
-C, --directory=DIR
Change to DIR before performing any operations. This option is order-sensitive,
i.e. it affects all options that follow.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question