Re: [newbie] adding date to tar.gz file?

2002-03-26 Thread Jon Doe

On Tue, 26 Mar 2002 19:50:09 -0500
Hanan Shargi <[EMAIL PROTECTED]> wrote:

> Jhon,
> 
> Wold you do me a favoure and post that script ? 
> 
> :)
> 
> -
> Hanan AL-Shargi

I don't mind at all. Just keep in mind that this is a simple backup for my bookmarks 
and a couple other things, not an entire system or home directory backup.
I'm sure there are plenty of better ways to accomplish this also. This just happens to 
be one that I figured out on my own (aside from the date thing :))


#!/bin/sh
backupname="backup-$(date +%m-%d-%y)"
mkdir /home/jon/backup/sylpheed/
mkdir /home/jon/backup/gaimlogs/
cp /home/jon/.netscape/bookmarks.html /home/jon/backup/
cp /home/jon/.gaim/logs/* /home/jon/backup/gaimlogs/
cp /home/jon/.kde2/share/apps/konqueror/bookmarks.xml /home/jon/backup/
cp /home/jon/.sylpheed/* /home/jon/backup/sylpheed/
tar -czf $backupname.tar.gz backup
rm -r /home/jon/backup/*



Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com



Re: [newbie] adding date to tar.gz file?

2002-03-26 Thread Jon Doe

Thanks! 
Thats exactly what I was looking for!
Reading man date right now :)

Sheesh, been using linux for over a year now and still feel like a newbie...lol.



Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com



Re: [newbie] adding date to tar.gz file?

2002-03-26 Thread Miark

Jon,

Well, since Gerald was kind enough to help me out with some
programming, here's my opportunity to give back in kind :-)
The following Perl script will do what you want, as I don't
know of any tar command that will.

Run this script as a cron job.

Miark


--- The following line is the first line of the script --
#!/usr/bin/perl

$precious_data = "~/whatever"; # What do you want to backup?
$archive_dir   = "~/wherever"; # In which dir do you store backups?

$date = `date +%m-%d-%y`;  chomp($date);
$archive_file = "backup-${date}.tar.gz";
$archive_path = $archive_dir . "/" . $archive_file;
$tar_command = "tar -czf $archive_path $precious_data";

exec $tar_command;



Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com



Re: [newbie] adding date to tar.gz file?

2002-03-26 Thread Miark

Yes, I do everything the hard way :-)  

Didn't even occur to me to use the back ticks in the 
command itself. Shows you how often I use back ticks.

Miark



Tim Holmes <[EMAIL PROTECTED]> spoke thusly:

> Just add an executable line to the name of the tar.gz by using date.
> Pretty simple.  I do it all the time.
> 
> tar -zxf /path/to/file-`date +%m-%d-%y`.tar.gz /path/to/dir/to/backup
> 
> You'll end up with /path/to/file-03-26-02.tar.gz
> 
> Check out date --help for all the possible flags, so you can get your
> tar file as specific as you'd like.  Including the time, just the day
> and month, format, etc;
> 
> Hope that helps ya.
> tdh
> 
> -- 
>  
>  T. Holmes  |  UNIXTECHS.org  |  [EMAIL PROTECTED]  |  UIN:  17021091
>  
> | I have a script I use to backup some important files in my home directory. It 
>works fine but I would like it to add the curent date to the file name IE: 
>backup-03-26-02.tar.gz instead of just backup.tar.gz
> | Any suggestions on how to do this? I looked in the tar man and tar howto but 
>couldn't find exact syntax for the current date.
> | thanks
> | 
> 
> | Want to buy your Pack or Services from MandrakeSoft? 
> | Go to http://www.mandrakestore.com
> 
> `--- 
> 
> 



Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com



Re: [newbie] adding date to tar.gz file?

2002-03-26 Thread Tim Holmes

Just add an executable line to the name of the tar.gz by using date.
Pretty simple.  I do it all the time.

tar -zxf /path/to/file-`date +%m-%d-%y`.tar.gz /path/to/dir/to/backup

You'll end up with /path/to/file-03-26-02.tar.gz

Check out date --help for all the possible flags, so you can get your
tar file as specific as you'd like.  Including the time, just the day
and month, format, etc;

Hope that helps ya.
tdh

-- 
 
 T. Holmes  |  UNIXTECHS.org  |  [EMAIL PROTECTED]  |  UIN:  17021091
 
| I have a script I use to backup some important files in my home directory. It works 
|fine but I would like it to add the curent date to the file name IE: 
|backup-03-26-02.tar.gz instead of just backup.tar.gz
| Any suggestions on how to do this? I looked in the tar man and tar howto but 
|couldn't find exact syntax for the current date.
| thanks
| 

| Want to buy your Pack or Services from MandrakeSoft? 
| Go to http://www.mandrakestore.com

`--- 



Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com



[newbie] adding date to tar.gz file?

2002-03-26 Thread Jon Doe

I have a script I use to backup some important files in my home directory. It works 
fine but I would like it to add the curent date to the file name IE: 
backup-03-26-02.tar.gz instead of just backup.tar.gz
Any suggestions on how to do this? I looked in the tar man and tar howto but couldn't 
find exact syntax for the current date.
thanks



Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com