Results 1 to 3 of 3
Hi,
I'm trying to make a script that I'd add to cron that would pack some files in an archive file and prifix the curent date to the filename.
Curently ...
- 11-26-2006 #1Just Joined!
- Join Date
- Apr 2006
- Location
- Slovenia
- Posts
- 79
Archive Script
Hi,
I'm trying to make a script that I'd add to cron that would pack some files in an archive file and prifix the curent date to the filename.
Curently this is how it's setup:
But I still don't know how to make the archive into a zip file and how to prifix the date into the filename. Something like /home/user/archive/26-11-2006_filename.zip .Code:tar -c /home/user/archive/filename.tgz /home/user/folder/*.gif /home/user/folder/*.jpg /home/user/folder/*.png
Thanks for the help
- 11-26-2006 #2
This information is all available in the man pages for tar and date.
Code:[hector@troy ~]$ date +%d-%m-%Y 26-11-2006
Finally, you can simply mv the filename such that it's prefixed with the date. Example: BACKUP1=/some/file1Code:[hector@troy ~]$ tar czf backup somefile1 [hector@troy ~]$ file backup backup: gzip compressed data ...
DATE1=$(date +%d-%m-%Y)
mv "$BACKUP1" "$DATE1"_"$BACKUP1"
- 11-27-2006 #3Just Joined!
- Join Date
- Apr 2006
- Location
- Slovenia
- Posts
- 79
Cool, thank you >anomie< it works great.
Thanks again


Reply With Quote