Unix Shell - Image versioning system.

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > March 2006 > Image versioning system.





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Image versioning system.
alan@ugtv.org

2006-03-13, 5:54 pm

I'm trying to create an image versioning system.
Currently the way the system works is:
There is a live server and a backup server.
Every day every file on the live server is checked to see what is the
file's modification date.
The modification date is compared against the folder structure to see
if the file exists and if it is newer. If the live server file is
newer it's copied to the bacup server.

For Instance
Live Server
Image001.jpg Modified 03-11-2006

Backup Server
Folder Image001
-->Folder March
-->Folder Day01
-->Image001.jpg Modified 03-01-2006
-->Folder Day05
-->Image001.jpg Modified 03-05-2006
-->Folder Day11
-->Image001.jpg Modified 03-11-2006

The problem is:
I need to be able to read the modification date from the file using a
UNIX shell script. (It doesn't matter which shell.) I've tried using
ls and AWK, but I can't find a way to express the ls timestamp in
YYYYMMDD terms.

If anyone else can think of a way around this, or a way to do this, I'm
all ears. Sorry for the long explanation.

Kurt Swanson

2006-03-13, 5:54 pm

alan@ugtv.org writes:
> I'm trying to create an image versioning system.
> Currently the way the system works is:
> There is a live server and a backup server.
> Every day every file on the live server is checked to see what is the
> file's modification date.
> The modification date is compared against the folder structure to see
> if the file exists and if it is newer. If the live server file is
> newer it's copied to the bacup server.


> For Instance
> Live Server
> Image001.jpg Modified 03-11-2006


> Backup Server
> Folder Image001
> -->Folder March
> -->Folder Day01
> -->Image001.jpg Modified 03-01-2006
> -->Folder Day05
> -->Image001.jpg Modified 03-05-2006
> -->Folder Day11
> -->Image001.jpg Modified 03-11-2006


> The problem is:
> I need to be able to read the modification date from the file using a
> UNIX shell script. (It doesn't matter which shell.) I've tried using
> ls and AWK, but I can't find a way to express the ls timestamp in
> YYYYMMDD terms.


> If anyone else can think of a way around this, or a way to do this, I'm
> all ears. Sorry for the long explanation.


Why not just use rsync? (Maybe there's something I'm missing)

Otherwise, gnu ls does have a -time-style option: ls -l --time-style=+%y%m%d
--
© 2006 Kurt Swanson AB
alan@ugtv.org

2006-03-13, 5:54 pm

Thanks for the response, I'll look into GNU.
In regards to the rsync, that won't work because we're trying to get a
version history started. If we used rsync, it would just replace the
old with the new.

Kevin Rodgers

2006-03-13, 5:54 pm

Use rsync's -n option (aka --dry-run) to tell you what files need to be
updated.
--
Kevin Rodgers

Kurt Swanson

2006-03-13, 5:54 pm

alan@ugtv.org writes:
> Thanks for the response, I'll look into GNU.
> In regards to the rsync, that won't work because we're trying to get a
> version history started. If we used rsync, it would just replace the
> old with the new.


In it's base form, yes, but consider rsync's "--backup" and related options.
--
© 2006 Kurt Swanson AB
alan@ugtv.org

2006-03-17, 8:53 pm


Kurt Swanson wrote:
> alan@ugtv.org writes:
>
> In it's base form, yes, but consider rsync's "--backup" and related optio=

ns.
> --
> =A9 2006 Kurt Swanson AB


Rsync works great, but I can't get it to run as a CRON job.
I wrote a script that grabs the last group of folder names in a list
and only backs those up.
Any help would be great on what I'm doing wrong.

#!/bin/bash
mkdir /Volumes/image/
mount_afp afp://username:password@192.168.0.100/Images/ /Volumes/image
j=3D`ls /Volumes/image/ | grep [0-9] | tail -5`
for k in $j
do
echo $k
rsync -vr --verbose --recursive --times --archive --backup
--backup-dir=3D"/Volumes/FireWire/Backup/`date +%Y%m%d`"
/Volumes/image/$k /Volumes/FireWire/$k
done
umount /Volumes/image

Kurt Swanson

2006-03-17, 8:53 pm

alan@ugtv.org writes:
> Kurt Swanson wrote:
[vbcol=seagreen]
[vbcol=seagreen]
> Rsync works great, but I can't get it to run as a CRON job.
> I wrote a script that grabs the last group of folder names in a list
> and only backs those up.
> Any help would be great on what I'm doing wrong.


> #!/bin/bash
> mkdir /Volumes/image/
> mount_afp afp://username:password@192.168.0.100/Images/ /Volumes/image
> j=`ls /Volumes/image/ | grep [0-9] | tail -5`
> for k in $j
> do
> echo $k
> rsync -vr --verbose --recursive --times --archive --backup
> --backup-dir="/Volumes/FireWire/Backup/`date +%Y%m%d`"
> /Volumes/image/$k /Volumes/FireWire/$k
> done
> umount /Volumes/image


What is the symptom, i.e. what is going wrong? Is there an error
message?
--
© 2006 Kurt Swanson AB
Bill Marcum

2006-03-19, 12:02 pm

On 17 Mar 2006 17:10:01 -0800, alan@ugtv.org
<alan@ugtv.org> wrote:
>
> Rsync works great, but I can't get it to run as a CRON job.

Maybe you need to use the full path, i.e. /usr/bin/rsync or
/usr/local/bin/rsync


--
If at first you fricasee, fry, fry again.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com