Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Help w/Tar backup script
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
fincoop
Tux's lil' helper
Tux's lil' helper


Joined: 02 Feb 2004
Posts: 143

PostPosted: Sun Jul 11, 2004 11:39 am    Post subject: Help w/Tar backup script Reply with quote

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
View user's profile Send private message
ralph
Advocate
Advocate


Joined: 02 Mar 2003
Posts: 2001
Location: Hamburg

PostPosted: Sun Jul 11, 2004 12:07 pm    Post subject: Reply with quote

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
View user's profile Send private message
fincoop
Tux's lil' helper
Tux's lil' helper


Joined: 02 Feb 2004
Posts: 143

PostPosted: Sun Jul 11, 2004 12:38 pm    Post subject: Reply with quote

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
View user's profile Send private message
vonhelmet
l33t
l33t


Joined: 06 Apr 2004
Posts: 770
Location: Somewhere in a school

PostPosted: Sun Jul 11, 2004 12:42 pm    Post subject: Re: Help w/Tar backup script Reply with quote

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
View user's profile Send private message
fincoop
Tux's lil' helper
Tux's lil' helper


Joined: 02 Feb 2004
Posts: 143

PostPosted: Sun Jul 11, 2004 12:56 pm    Post subject: Re: Help w/Tar backup script Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum