RE: How do I do this in bash ??
[jeremy@MERCURY:pts/1:~]$ crontab -l 0 8 * * * /home/jeremy/bin/backupmail.sh [jeremy@MERCURY:pts/1:~]$ cat ~jeremy/bin/backupmail.sh #!/bin/bash FILENAME=/home/jeremy/backups/mail/`date -I`.tar cd ~jeremy/ /bin/tar -chf $FILENAME mail/* HTH, j. -- Jeremy L. Gaddis <[EMAIL PROTECTED]> <http://www.gaddis.org> > -Original Message- > From: Dave Selby [mailto:[EMAIL PROTECTED]] > Sent: Sunday, January 19, 2003 5:49 AM > To: Debian > Subject: How do I do this in bash ?? > > > Hi all ... > > I am writting a weekly automated backup script, very simple .. tars a > directory called 'myfiles' to a second hard drive. > > Works AOK except I want the name of the file written by tar > to be the time > and date. So I get a list of tared dated backups > > I know 'date' gives me exactly what I want but I cant figure > out how to get > tar to write a file with the value of date as its file name ... > > > #! /bin/sh > > # Backup entire 'myfiles/' directory, name it with the date. > > cd /usr/local/ > tar -czf /mnt/archive/autoarchive/date myfiles > > > I put this in /etc/cron.weekly and I get a file called date !!??? > I have tried '' and "" all to no avail > > Any hints ?? > Dave > > > -- > To UNSUBSCRIBE, email to [EMAIL PROTECTED] > with a subject of "unsubscribe". Trouble? Contact > [EMAIL PROTECTED] > -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: How do I do this in bash ??
On Sunday 19 January 2003 10:48 am, Dave Selby wrote: > Hi all ... > > I am writting a weekly automated backup script, very simple .. tars a > directory called 'myfiles' to a second hard drive. > > Works AOK except I want the name of the file written by tar to be the time > and date. So I get a list of tared dated backups > > I know 'date' gives me exactly what I want but I cant figure out how to get > tar to write a file with the value of date as its file name ... > > > #! /bin/sh > > # Backup entire 'myfiles/' directory, name it with the date. > > cd /usr/local/ > tar -czf /mnt/archive/autoarchive/date myfiles > > > I put this in /etc/cron.weekly and I get a file called date !!??? > I have tried '' and "" all to no avail > > Any hints ?? > Dave Many many thanks for all your suggestions !! You have all been a great help, Auto updating should be on line in approx 10 mins complete with date !! Dave -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: How do I do this in bash ??
On Sun, Jan 19, 2003 at 10:48:43AM +, Dave Selby wrote: > I am writting a weekly automated backup script, very simple .. tars a > directory called 'myfiles' to a second hard drive. > > Works AOK except I want the name of the file written by tar to be the time > and date. So I get a list of tared dated backups > > I know 'date' gives me exactly what I want but I cant figure out how to get > tar to write a file with the value of date as its file name ... > > > #! /bin/sh > > # Backup entire 'myfiles/' directory, name it with the date. > > cd /usr/local/ > tar -czf /mnt/archive/autoarchive/date myfiles > > > I put this in /etc/cron.weekly and I get a file called date !!??? > I have tried '' and "" all to no avail What you want is backticks (`date`). Since date's default output isn't very good as a filename you probably want to specify the output format. I would use something like this: tar czf /mnt/archive/autoarchive/`date '+%Y%m%d'`.tar.gz myfiles which would give you a file named 20030119.tar.gz. The reason I use year-month-day format is that the alphabetical sorting that ls does by default will match the chronological order of the files. -- Michael Heironimus -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: How do I do this in bash ??
> #! /bin/sh > > # Backup entire 'myfiles/' directory, name it with the date. > > cd /usr/local/ > tar -czf /mnt/archive/autoarchive/date myfiles man bash(1): Command substitution allows the output of a command to replace the command name. There are two forms: $(command) or `command` So your command goes: tar -czf /mnt/archive/autoarchive/`date` myfiles greetings, Johannes -- "More than machinery we need humanity" -- Charlie Chaplin, The Great Dictator -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: How do I do this in bash ??
Hi, * Dave Selby <[EMAIL PROTECTED]> [2003-01-19 11:48]: >I know 'date' gives me exactly what I want but I cant figure out how to get >tar to write a file with the value of date as its file name ... Basically, tar czf myFiles.`date`.tar.gz myfiles though that gets you whitespaces in the file name. You should use date(1) with a format string, have a look in date's manpage. Thorsten -- Intolerant people should be shot. msg24897/pgp0.pgp Description: PGP signature
Re: How do I do this in bash ??
* Dave Selby <[EMAIL PROTECTED]> [2003-01-19 12:10]: > > #! /bin/sh > > # Backup entire 'myfiles/' directory, name it with the date. > > cd /usr/local/ > tar -czf /mnt/archive/autoarchive/date myfiles > tar czf /`date +%Y%m%d-%H%M`.backupmyfiles.tar.gz tar cjf /`date +%Y%m%d-%H%M`.backupmyfiles.tar.bz2 * * note the inverted accents! results in20030119-1213.backupmyfiles.tar.bz2 I would make use of the second form since the files get remarkably smaller! wbr, Lukas -- Lukas Ruf http://www.lpr.ch Wanna know anything about raw ip? Join [EMAIL PROTECTED] on http://www.rawip.org -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
How do I do this in bash ??
Hi all ... I am writting a weekly automated backup script, very simple .. tars a directory called 'myfiles' to a second hard drive. Works AOK except I want the name of the file written by tar to be the time and date. So I get a list of tared dated backups I know 'date' gives me exactly what I want but I cant figure out how to get tar to write a file with the value of date as its file name ... #! /bin/sh # Backup entire 'myfiles/' directory, name it with the date. cd /usr/local/ tar -czf /mnt/archive/autoarchive/date myfiles I put this in /etc/cron.weekly and I get a file called date !!??? I have tried '' and "" all to no avail Any hints ?? Dave -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]