I have this command
tar -czf /var/log/apache2/logfile_backups/dBackup_$(date "+%d-%m-%Y").tar.gz /var/log/apache2/ --exclude=/var/log/apache2/logfile_backups --exclude='*.sh'
First, I run this command in a SSH-Console (Putty), everything works great!
Second, I write a bash-Script (myscript.sh)
#!/bin/bash
tar -czf /var/log/apache2/logfile_backups/dBackup_$(date "+%d-%m-%Y").tar.gz /var/log/apache2/ --exclude=/var/log/apache2/logfile_backups --exclude='*.sh'
And start this script in SSH-Console with bash ./myscript.sh
, but the result at the end is not the same. The tar
-command ignores the second --exclude
parameter.
What's wrong? I think, a bash script is the same as a SSH-console like Putty.