A Batch File that Uploads/Backs-up to FTP

Friday, February 15, 2008

This is something really simple but I find it really useful for a number of tasks.

it's basically a batch file that connects to any FTP webspace and uploads files. The good thing about it is that you can give clients a means of uploading a file by just double-clicking. You can also schedule the batch file to run using Task Scheduler in Windows.

I have set it up on one of my dedicated servers as a Scheduled Task so that first a command-line zip utility zips my clients entire website, I then use this Scheduled batch file to upload/backup to webspace hosted with the same company, which means the webspace is on the same network and therefore the upload takes a 30 seconds for a 200Mb backup, and the files are on a completely different server - Great!

Batch file contents (FtpUpload.bat)
This is the file that you can schedule, it merely contains the location of the ftp instructions file that you wisdh to run (make sure you change the file path accordingly), and the ftp hostname.

ftp -s:
C:\PathofFiles\FtpAccountAndFiles.ftp
yourhostname.com

Ftp instructions file contents (FtpAccountAndFiles.ftp)
This is the file that contains your ftp username, password and the files you wish to upload, in this case an example file (stored in the same directory as the batch file).

yourftpusername
yourftppassword
put ExampleFile.txt
quit

Hey presto! There you go, a free upload or backup solution!

Here are the files (Zip, 1Kb)

Now to use it as a backup solution you will need compression software to make it easier! - my solution...

First you will have to download and install WinRar trial (version 3.71 at time of writing) from http://www.rarlabs.com/download.htm - This version hasn't changed for ages (years!?), if unregistered all you get is a small nag screen (no functionality is taken away). I think WinRar is the best archiving software availible! - Why? because of the simple context menu (right-click) operations for zipping and un-zipping and also many powerful yet easy to use functions such as the self-extracting executable setup and of course the command-line archiving functionality of which we are going to use..

When we have WinRar installed, the below code, when added to the top of your batch file will compress your files (into one file) so you can upload it with the above batch script.

c:\Program Files\WinRar\winrar a -r0 -x*.dll -x*.rws -x*.rar "D:\BackupsForUpload\YourWebsite.rar" "D:\home\yourwebsite.co.uk\htdocs\*.*"

(Note: the above is all on one line if it appears differently on the page)

Basically the aboveline is telling WinRar to create an archive and add all the files from the mentioned location to the rar file. Voila!

Simple Guide to put a Google Location Map on Your Website

Sunday, February 10, 2008

Why draw or pay for a location map for your client when you can quite simply and easily give them a google location map that looks stunning and works great.

The google maps API has absolutely loads of options e.g. multiple markers, journeys etc but all I'm demonstrating is a simple map, with an address marker.

You have to put the following into the start tag of your <body> marker..

onload="load()"

 ..so it might look a bit like this..

<body onload="load()">

..all this does is load the google map.

You then need to paste the below code into your main page content area (or where you want the map to appear). Note will you have to change a couple of variables before your map will appear - listed below.

<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=YOURKEYHERE" type="text/javascript">
</script>

<script type="text/javascript">
 
var WINDOW_HTML = '<div style="width: 200px; padding-right: 10px"><strong>My Clients Company Name</strong><br>Address1<br>Address 2<br>Postcode etc.</div>'; 
    //<![CDATA[
    function load() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
      map.addControl(new GSmallMapControl());

      map.setCenter(new GLatLng(51.36445,0.3698), 13);
      var marker = new GMarker(new GLatLng(51.36445,0.3698));
      map.addOverlay(marker);
      GEvent.addListener(marker, "click", function() {
        marker.openInfoWindowHtml(WINDOW_HTML);
      });
      marker.openInfoWindowHtml(WINDOW_HTML);
      }
    }
    //]]>
</script>

<div id="map" style="border: 1px solid #979797; background-color: #e5e3df; width: 540px; height: 360px; margin: auto; margin-top: 2em; margin-bottom: 2em">
<div style="padding: 1em; color: gray">Loading...</div>
</div>

1) get your API Key by visiting http://code.google.com/apis/maps/signup.html all you have to do is tick a box and enter the URL of your website to get your key. You will need to paste your key OVER the YOURKEYHERE part of the above code.

2) Change the WINDOW_HTML value to the address (and maybe phone number) of your location (or anything you wish for that matter) - you can use html. 

3) You see that there are two numerical values following the GLatLng(lat, and long) -in the code above. You need to do is replace these with the co-ordinates of the place you wish to center on the map. How do I get these? I hear you ask. The way I get these is go to www.multimap.com, type in the postcode and then scroll to the bottom of the page for the "lat" and "long" numbers.

4) You can set the height, width and border of your map by editing the last <div> of the above code. 

Finally I've found a decent bit of FTP software - and it's free!

Tuesday, January 15, 2008

Over the years developing websites, I've struggled to find a decent bit of FTP software that meets all the criteria that I wish for, all I ask is that it does a couple of things..

1. It's freeee.

2. It's reliable.

3. The layout is relatively easy to use, i.e. pretty standard, left-to-right drag and drop functionality.

4. It can store a (managable) directory of my sites.

5. It allows me to back up the many sites that I have stored.

Well Filezilla is the answer! The backup utility is great! - it exports all your sites into an xml file, ready for import or backup. No longer will I kick my computer because I've lost all my FTP site entries, well done Tom Kosse!

FileZilla Logo

Website: http://filezilla-project.org 

Home Antivirus Software? Free?

Monday, January 14, 2008

There is loads of antivirus software out there, ranging from stuff that has loads of adware built in, is watching your every move and reports hugely exagerated results (ahem SystemDoctor) to stuff that costs you £300+.

For the home market I've tried numerous antivirus software products and I've found one that's free and I'm happy to stick with. Avast Antivirus from Alwil Software.

All you have to do is download the home edition from the downloads section of the Avast website. (http://www.avast.com/eng/programs.html), register your email address and they send you a home license code. Presto!

Places to get Stock Photography for Cheap or Free!

Monday, January 14, 2008

Im going to use this page as a place of reference for image librarys that I've found to be good value.

Stock Exchange
Website: http://sxc.hu
Free pictures, vast collection - some pics need uploaders' concent.

Stock Expert
Website: www.stockexpert.com
Stock exchanges sister company, excellent quality pictures from $1 (Approx 50p) Just sign up an account and away you go!

Morgue File
Website: www.morguefile.com
Another free site for stock photography.

Feed Shark