View previous topic :: View next topic |
Author |
Message |
fincoop Tux's lil' helper
Joined: 02 Feb 2004 Posts: 143
|
Posted: Sun Jul 11, 2004 11:39 am Post subject: Help w/Tar backup script |
|
|
I found some threads on this forum, which have gotten me this far. I had it working but then I tried to add the date to the filename, and now Tar is angry.
Code: |
cron.daily # cat backup.cron
#!/bin/bash
#
# Backup Script
TARGET='server-$(date +%Y%m%d).tgz'
DIRS='/etc/ /var/www/localhost/htdocs/ /var/bind/ /home/'
EXCL='/etc/backup.excl'
cd /share/backup
tar cvpzf $TARGET -X $EXCL $DIRS >> /var/log/backup$(date +%Y%m%d).log
find . -mtime +7 -exec rm {} \;
emerge -pev world > /share/backup/emerge.list
|
Code: |
etc # cat backup.excl
/var/www/localhost/htdocs/pics/*
/var/www/localhost/htdocs/cdlist/*
/var/www/localhost/htdocs/dvdlist/*
/var/www/localhost/htdocs/manual/*
/var/www/localhost/htdocs/cdlist/*
|
Error:
Code: |
./backup.cron: line 5: +%Y%m%d).tgz: command not found
|
[/code] |
|
Back to top |
|
|
ralph Advocate
Joined: 02 Mar 2003 Posts: 2001 Location: Hamburg
|
Posted: Sun Jul 11, 2004 12:07 pm Post subject: |
|
|
Try to put backqoutes around the date command:
server-`date +%Y%m%d`.tgz _________________ The computer can't tell you the emotional story. It can give you the exact mathematical design, but what's missing is the eyebrows.
- Frank Zappa |
|
Back to top |
|
|
fincoop Tux's lil' helper
Joined: 02 Feb 2004 Posts: 143
|
Posted: Sun Jul 11, 2004 12:38 pm Post subject: |
|
|
ralph wrote: | Try to put backqoutes around the date command:
server-`date +%Y%m%d`.tgz |
Thanks, tried that, double-quotes too. I have the same config on pipe to the backup log, and that works. |
|
Back to top |
|
|
vonhelmet l33t
Joined: 06 Apr 2004 Posts: 770 Location: Somewhere in a school
|
Posted: Sun Jul 11, 2004 12:42 pm Post subject: Re: Help w/Tar backup script |
|
|
fincoop wrote: | tar cvpzf $TARGET -X $EXCL $DIRS >> "/var/log/backup$(date +%Y%m%d).log" |
Maybe that?
I think you probably need quotes around the whole thing, as otherwise tar will freak out at the space. Actually, it's freaking out at the $(...) bit because otherwise it wouldn't care about the space...
Maybe if you find out the date earlier in the script and export it to a variable then put that variable in? Then you won't need any spaces or anything. _________________ My blog
nvtuner software - enhance your AGP Geforce 6800 or 6200! |
|
Back to top |
|
|
fincoop Tux's lil' helper
Joined: 02 Feb 2004 Posts: 143
|
Posted: Sun Jul 11, 2004 12:56 pm Post subject: Re: Help w/Tar backup script |
|
|
vonhelmet wrote: | fincoop wrote: | tar cvpzf $TARGET -X $EXCL $DIRS >> "/var/log/backup$(date +%Y%m%d).log" |
Maybe that?
I think you probably need quotes around the whole thing, as otherwise tar will freak out at the space. Actually, it's freaking out at the $(...) bit because otherwise it wouldn't care about the space...
Maybe if you find out the date earlier in the script and export it to a variable then put that variable in? Then you won't need any spaces or anything. |
I tried that too, but the space is still there when the command is executed, because the variable expands to whatever its definition. At this point, I'm considering using logrotate to deal with my backup file |
|
Back to top |
|
|
|