HTTrack Website Copier
Free software offline browser - FORUM
Subject: Re: How to update local website to local directory?
Author: eric
Date: 08/31/2011 18:17
 
It's not the "ALL" that I don't understand, it was just a question if it was
also possible to update (only copy newer files)... apparently not, at least
not without using a script.

I can not use your script, because I'm on a Linux computer. But I have made a
script on my own and it is used with the "-V" option of HTTrack.

For those who are interested:

You have to let httrack make a copy (or mirror) on a temporary directory. I
prefer a RAM disk because it is fast.

To be clear, there are 3 important filenames:
$file_temp = temporary file (preferably inside a RAM disk)
$file_original = original file
$file_copy = the file that should be a copy of the original file

Using the "-V \$0" option, HTTrack will execute a script after every file it
writes on this temporary directory ($file_temp). HTTrack will "give" the
filename of this file to the script.

The script should "convert" this filename.
for example:
given filename: /tmp/web/localhost/home/usr/pictures/123.jpg
$file_temp = filename
$file_original = filename without '/tmp/web/localhost'
$file_copy = filename but '/tmp/web/localhost' replaced by '/usb/web'

Now the script should check if $file_copy exists, even if it is an older
version of this file. If not, the script should also check if the directory
where this $file_copy should be exists.

Now, the script should check if $file_original is newer than $file_copy.
If yes, then move $file_temp to $file_copy.
If not, then delete $file_temp to not fill the RAM disk with unneeded files.

This script wil be run everytime after a file is written on the temporary
directory by HTTrack.

The script below is untested, because my situation is a bit different (I'm
using the '-N99' option of HTTrack which will change the filenames and
directory structure).

#################################
#!/bin/sh

# convert filename
file_temp="${1}"
file_original="${file_temp#/tmp/web/localhost}"
file_copy="${file_temp/\/tmp\/web\/localhost/\/usb\/web}"

# does a copy of the file exist?if [ ! -f "${file_copy}" ]; then
  # no, moving temp to copy
  # but first, does the directory exist?  if [ ! -d "${file_copy%/*}" ]; then
    # no, create it
    mkdir -p "${file_copy%/*}"
  fi
  mv "${file_temp}" "${file_copy}"
  exit 0
fi

# so, a copy exists, but should it be updated?if [ "${file_original}" -nt
"${file_copy}" ]; then
  # yes, moving temp to copy
  mv "${file_temp}" "${file_copy}"
else
  # no, remove temp file
  rm "${file_temp}"
fi

exit 0
#################################
 
Reply Create subthread


All articles

Subject Author Date
How to update local website to local directory?

08/30/2011 18:31
Re: How to update local website to local directory?

08/30/2011 21:17
Re: How to update local website to local directory?

08/31/2011 00:59
Re: How to update local website to local directory?

08/31/2011 16:47
Re: How to update local website to local directory?

08/31/2011 16:50
Re: How to update local website to local directory?

08/31/2011 18:17




6

Created with FORUM 2.0.11