Sample Header Ad - 728x90

Tar exclude parameter in bash script not working

0 votes
3 answers
417 views
I got a tar command line that works great straight in the shell. tar --exclude=out/pictures/\*.{jpg,gif,png,jpeg} --exclude=tmp/\*.{txt,php} --exclude=log/\*.{log,sql} -cvf /backups/mydomain.tar -C /var/www/vhosts/mydomain.com/httpdocs content As soon as I put this command in a bash script and execute, it ignores the excludes parameters. I tried some various syntax like: tar --exclude="out/pictures/\*.{jpg,gif,png,jpeg}" -cvf /backups/mydomain.tar -C /var/www/vhosts/mydomain.com/httpdocs content tar --exclude='out/pictures/\*.{jpg,gif,png,jpeg}' -cvf /backups/mydomain.tar -C /var/www/vhosts/mydomain.com/httpdocs content tar --exclude out/pictures/\*.{jpg,gif,png,jpeg} -cvf /backups/mydomain.tar -C /var/www/vhosts/mydomain.com/httpdocs content tar --exclude= out/pictures/\*.{jpg,gif,png,jpeg} -cvf /backups/mydomain.tar -C /var/www/vhosts/mydomain.com/httpdocs content But nothing works. The exclude parameters are simply ignored. A simple --exclude like --exclude="tmp" works as intended. As soon I start to work with parameters it breaks cause of the syntax I assume. Im running tar (GNU tar) 1.29 on ubuntu 18.04.5.
Asked by Kuba (1 rep)
Oct 13, 2020, 03:44 PM
Last activity: Oct 14, 2020, 11:11 AM