Easly
Easly

Reputation: 334

Rsync and dynamic exclude

i'm trying to make this little script work, but i'm missing something..

exclude=""
while read line
do
    exclude+="--exclude $line "
done < exclude.ini
echo "$exclude"
"rsync -rvi --delete $exclude /var/www/$1 /var/export"

The script is reading the files that needs to exclude from a file, but i'm not able to concatenate properly those string

The entries in the file are written like this .svn _svn .htaccess ReadAndDeleteMe.ini cache/* documentation

anyone can help ?

Upvotes: 1

Views: 447

Answers (1)

enzotib
enzotib

Reputation: 1644

I would use

--exclude-from=exclude.ini

In fact the man page says:

   --exclude-from=FILE
          This option is related to the --exclude option, but it specifies
          a FILE that contains exclude patterns  (one  per  line).   Blank
          lines  in  the  file  and  lines  starting  with  ’;’ or ’#’ are
          ignored.  If FILE is -, the list  will  be  read  from  standard
          input.

Upvotes: 1

Related Questions