Re: Automated-backup script
From: Matt_left_coast (not_at_chance.org)
Date: 05/11/04
- Next message: David Warren: "Re: ext3 filesystem runs as ext2"
- Previous message: Daniel Lidstrom: "Re: Automated-backup script"
- In reply to: Daniel Lidstrom: "Re: Automated-backup script"
- Next in thread: Daniel Lidstrom: "Re: Automated-backup script"
- Reply: Daniel Lidstrom: "Re: Automated-backup script"
- Reply: Michael: "Re: Automated-backup script"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 11 May 2004 20:20:35 GMT
Daniel Lidstrom wrote:
> On Tue, 11 May 2004 16:23:58 +0000, Matt_left_coast wrote:
>
>> Daniel Lidstrom wrote:
>>
>>> Hi,
>>>
>>> I'm doing some backups for a friend. The script is placed in
>>> /etc/cron.daily and looks like this:
>>> #!/bin/bash
>>> wget http://www.sweden.se/ptk-src.tar.gz -P /backup/bobbo > /dev/null
>>> 2>&1
>>>
>>> This produces lots of ptk-src.tar.gz's in /backup/bobbo. I'd like to
>>> save only those that differ from previous versions. So, instead of
>>> having ptk-src.tar.gz.1, ptk-src.tar.gz.2, etc, that are all the same
>>> file, how can I save only the one that differs from previous? I don't
>>> mind the numbering, infact I think it is good.
>>>
>>> Thanks a lot!
>>>
>>
>> You could write a script that does a checksum then save only the ones
>> where the checksums differ.
>
> If I knew how to write that script, it would already be done :-)
Perhaps it is time to learn.
> My idea is the following:
> 1) download the backup file
> 2) find out what name it was given (by finding the latest modified file)
> 3) By name of file, I know what is the next-latest file (last
> character of file, if it is a digit, minus 1)
> 4) Compute checksums for both files.
> 5) If equal, remove latest file
> 6) Else, do nothing
>
> Anybody who is fluid with scripts that can help me?
> Thanks in advace.
>
The last I checked, this group is not a script writing service.
I would suggest you look into rsync over ssh rather than wget. If you insist
on wget, may I suggest you rethink the methodology?
Make two directories: download and backup
use wget to download all the files to download
then do a "for file in download/*; do" (examples are in your /etc/init.d
scripts) loop to compare the checksum of $file in download to the
$file.<timestamp> of the latest $file (an ls download/$file* piped to sort
piped to tail -1 will give you the latest file if you have the timestamp
done right) in backup to the files in backup, if they differ mv $file to
download/$file.<timestamp> else rm download/$file
You would want to make sure that download is cleared out before the loop is
started (rm -rf download/*). To do the time stamp use the date command to
set a variable:
timestamp=`date <format options you want>` before the loop. Then when you mv
the file it would be something like
mv download/$file backup/$file.$timestamp
if the checksums are different.
I'm not trying to be an ass, but I am trying to encourage you to learn
scripting for yourself.
'give a man a fish and you feed him for a day, teach him how to fish and you
feed him for life' sort of thinking.
- Next message: David Warren: "Re: ext3 filesystem runs as ext2"
- Previous message: Daniel Lidstrom: "Re: Automated-backup script"
- In reply to: Daniel Lidstrom: "Re: Automated-backup script"
- Next in thread: Daniel Lidstrom: "Re: Automated-backup script"
- Reply: Daniel Lidstrom: "Re: Automated-backup script"
- Reply: Michael: "Re: Automated-backup script"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|