Set name of tar file as date using bash
Hey everybody. I have a bash question that is totally out of my league. What I would like to do is make a bash script that backups a folder to a tar.gz file on my backup drive. But I want the name of the file to be the date it was archived on. Heres what I have so far
#!/bin/sh mount /dev/sda1 /usr/backup/ tar -cvzf /usr/backup/(date of compress variable).tar.gz /var/www/html/ umount /dev/sda1 #thank you and have a nice day If anyone knows if there is a simple way to call the date down from bash I would love to know, and if its not so simple, then maybe some guidance. Thx |
Did you try 'date'?
It probably won't return the format you want, but check the manpages, or use sed to fix that. John |
Date
Hi,
I'm UNIX expert, but I think this should work : #!/bin/sh NOWDATE=`date +%d%m%y` mount /dev/sda1 /usr/backup/ tar -cvzf /usr/backup/$NOWDATE.tar.gz /var/www/html/ umount /dev/sda1 #thank you and have a nice day the date format is going to look like that : 181203 (for today's date), if you need different format (for example to add the time %H:%M:%S). Alf |
NOT UNIX expert
Sorry, I meant in my last posting to say: I'm NOT a UNIX expert.
Alf |
Heh-heh.
You can always just edit stuff like that. If you're quick, chances are that no-one will have noticed. John |
thanx
DUDE! it worked, thx alot
solution = `date +%m%d%y` |
All times are GMT -5. The time now is 05:51 PM. |