0

I have a simple bash script called script.sh

!#/bin/bash
tar czf /var/log/apache2/Backup_$(date "+%d-%m-%Y").tar.gz /var/log/apache2/ --exclude='backup*' --exclude='Backup*'

When I rund this line in SSH-Console, all works fine but when I run the .sh-script at linux console with bash ./script.sh

then the tar czf ... command works but ignore the --exclude parameters

Whats wrong? I don't know... :/

MLSC
  • 5,872
  • 8
  • 55
  • 89
Max Gunter
  • 213
  • 1
  • 14

2 Answers2

0

try this one:

UPDATE

#!/bin/bash
tar  -cZf /var/log/apache2/Backup_$(date +%Y%m%d).tgz.gz /var/log/apache2/ --exclude='backup*' --exclude='Backup*'

exclude is a pattern... see these helps: help1 help2 help3

Community
  • 1
  • 1
MLSC
  • 5,872
  • 8
  • 55
  • 89
0

you have to use :

!#/bin/bash
tar -czf /var/log/apache2/Backup_`date "+%d-%m-%Y"`.tar.gz /var/log/apache2/ --exclude='backup*' --exclude='Backup*'
PersianGulf
  • 2,845
  • 6
  • 47
  • 67