Link to home
Start Free TrialLog in
Avatar of choccarlm
choccarlm

asked on

Back ups

Hi, I've a written a small shell script that tar's certain directories and then moves the tar files to a backup directorie. Is it possible to add the time /date at the beginning of the tar files? I.E If the tar file is called website.tar, would it be possible using shellscript to call that file (date)20012210(&)(time)1100website.tar? I.E 200122101100website.tar. Meaning the backup was made at 11:00 on October 22nd 2001.
ASKER CERTIFIED SOLUTION
Avatar of dorward
dorward

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of choccarlm
choccarlm

ASKER

How do I assign the date to a constant. I need the date set to this because the script takes a while to run and it appends files to archives, and if the time changes in between, then it will attempt to add to an archive that doesnt exist. I.E when the script starts, it will create a tar file (-cvzf) with the time set as 0900, but when it gets further down the script, and has to append, the time would have changed. Thanks
bash, sh, ksh% date=`date +%Y%d%m%H%M`; tar cf backup-$date.tgz
csh, tcsh% set date = `date +%Y%d%m%H%M`; tar cf backup-$date.tgz