Robocopy - simple little backup script

June 27, 2009

I’ve been asked in the past to help out people (read family/friends, generally “love jobs”) with backing up stuff. Often there isn’t very much that needs to be backed up - what’s prompted this little script is a family member who just needs to backup about 4GB of stuff from a couple of folders.

Robocopy is something I’ve used in the past, and is a quick, easily scriptable little utility for moving stuff around in Windows. I’ve used it for all sorts of things, server migrations and stuff, for a number of reasons:
- it’s quick
- it’s simple
- it only copies the delta, and leaves stuff it’s already copied alone - this comes in particularly useful for when moving large quantities of files which are in use - you can “pre-stage” most of the stuff, and then it only copies what you need once you do the “final” copy.

Without further ado, here’s the script. It won’t be the best bit of scripting you’ve ever seen, but:

@echo off

REM Robocopy script

REM

REM This sets the main path for the backup. This is set a folder called backup in the current folde (ie. the USB key or wherever you're running this from)

set dest=%cd%\backup\

REM This sets the global options for the robocopy backups

set options=/E /ZB /COPYALL /MIR /R:3 /W:3 /V

REM each different folder you want to backup, and what folder you want it to be called in the destination.

REM comment out any that you don't need, and make sure the corresponding robocopy statement is also commented out.

REM ##########

set path=C:\Somefolder

set destfolder=Somefolder

robocopy %path% "%dest%%destfolder%" %options%

echo.

echo.

if errorlevel 16 echo ***FATAL ERROR*** Make sure all programs are closed and retry & echo. & echo. & pause & goto end

if errorlevel 8 echo **FAILED COPIES** Make sure all programs are closed and retry & echo. & echo. & pause & goto end

REM ##########

REM For each folder you want to backup, copy below

REM ##########

set path=C:\anotherfolder

set destfolder=anotherfolder

robocopy %path% "%dest%%destfolder%" %options%

echo.

echo.

if errorlevel 16 echo ***FATAL ERROR*** Make sure all programs are closed and retry & echo. & echo. & pause & goto end

if errorlevel 8 echo **FAILED COPIES** Make sure all programs are closed and retry & echo. & echo. & pause & goto end

REM ##########

:end

Basically, it sets as much of the “constant” stuff as it can for reuse with variables, and you just copy those chunks of code as required. There is basic error handling - if you run the batch and something goes wrong, it’ll stop and tell you.

Robocopy is available in the Windows resource kits. For more info, looky here. For download, go here.

Just make sure Robocopy.exe is on your USB key you’re running the script from, or in c:/windows/system32 (or somewhere else in your PATH variable)

I’m not going to document the whole thing - this is much for my reference as anyone else’s. Do some reading if you need to - the doco for Robocopy is very good, and there’s heaps of info out there.

Free Remote Access Software - Windows

June 21, 2009

I’ve had occasion in the past to provide remote support to people, and I’ve used this particular product before. Then I forgot what the hell it was called, so now I’m writing a blog post about it for me to look up when I forget it again!

It’s a service called LogMeIn. Basically, there’s a small client that you get the person you’re supporting to download and install, and once that’s done, they give you the username and password and you can remote desktop to their machine over the internets. I’ve found that it works nice, heaps better than the Remote Assistance “feature” in Windows, which I don’t think I’ve ever got working.

Apparently it even works on those “Apple” thingies.

The free version is available here: https://secure.logmein.com/products/free/

Flashblock

Given my recent Flash woes, I’ve come across this: http://flashblock.mozdev.org/

It’s been around for a while, and I’ve heard of it before, but haven’t got around to installing it until now. You can just add it through the Addins dialog in Firefox, and instead of your browser displaying all the crappy Flash content on every page (which is usually just ads anyway), it replaces it with an icon that you can click to selectively open.

In a completely unscientific test with Youtube, I’ve found it’s at least improved my experience. Maybe not quite 100%, but a LOT better.

Avast Free Antivirus for Windows

For a little while now, I’ve been recommending Avast to family/friends who need antivirus for their Windows machines. These are instructions so I can point people towards how to install and maintain Avast, so I’ve told you to come here and find this post, you’re at the right place!

Installing Avast:

To install the free version of Avast:
1. Click here to download: http://files.avast.com/files/latest/avast_home_setup.exe If that link is broken, let me know.
Alternatively, go to the Avast website free version download page - http://www.avast.com/eng/download-avast-home.html .
2. Once the file is downloaded, install it. Just follow the prompts, you can leave everything on defaults.
3. When it asks for the Registration Key, you’ll need to do the steps below

Getting your registration key for Avast Free version:
1. Click here: http://www.avast.com/eng/home-registration.php
2. Choose one of the 3 links up the top of the page:

- I’m a new user and I need a registration key for avast! Home Edition
- I’m a registered user, but I lost my registration key
- I’m a registered user and my registration key has expired, I need a new one

3. Follow the prompts, put in your details. They are a legit company, so don’t worry about providing your email address - I’ve never got any spam off them.

If Avast is saying that the registration is expiring/has expired, then you just need to follow the above steps to get a fresh key, which will cover you for the next 12 months.

Zimbra - Releasing quarantined emails

June 19, 2009

I’ve had someone send me an email with an encrypted ZIP file in it, which has got snagged in the Zimbra mail filter. Nice, just release it, right?

Not so easy.

I had a look through the admin console, and there’s no way of doing it through that. I’ve found this thread, which has a couple of methods to try it, and we’ll see which one works!

1. connect to the file system of your server (SSH or whatever)
2. browse to /opt/zimbra/data/amavisd/quarantine
3. The email should be there. When it was quarantined, you would have got an email containing: The message has been quarantined as: virus-DFSjhdshwkhed. That’s the name of the file
4. Copy the file somewhere different
5. Open the file in a text editor. It’ll show the email up the top, with the attachment below. Make sure you do actually want to open it!
6. Install uudeview if you don’t already have it:
apt-get install uudeview
7. run uudeview virus-DFSjhdshwkhed in the folder you copied it to before
8. Open ZIP file. Rejoice!

Joining MP3s

June 15, 2009

You wouldn’t believe how hard it was to find the answer to this (or maybe I was just asking the wrong question!).

I’ve been looking for software to join a bunch of MP3’s together - basically for mix CDs which end up with a bunch of separate mp3’s, and when played on a player end up with an annoying little gap between the tracks.

Hence, I’ve discovered mp3wrap. It’s available in the repos, and it’s as easy as doing the following in a folder full of the mp3’s you want to join:

mp3wrap -v myalbum.mp3 *mp3
(the -v lets you see what it’s doing)

It seems to stuff the time information (ie. the mp3 goes for over an hour but the progress bar says 3 min something). I’ll have to try it on an iPod and see how it goes.

(update) - looks like it doesn’t work that well - my mp3 stopped playing at the end of the first original track (in Totem). It still thinks it’s 3:30 long… Back to the drawing board…

Converting multiple jpg’s into one PDF

June 14, 2009

I’ve got a need to put a bunch of jpegs I’ve scanned into a PDF. Found this forum post: http://ubuntuforums.org/archive/index.php/t-808596.html

The thing I need is ImageMagick, which I’m installing from the packages.

Once installed, it’s as easy as running the following from a terminal (in the folder with the jpgs of course):
convert *.jpg MyNewPDF.pdf

Enabling 5.1 sound in 8.04 Hardy

I’m struggling to get 5.1 sound in Ubuntu, so I’ve found this site: http://ubuntulinuxhelp.com/enable-51-surround-sound-on-linux-ubuntu-804-hardy/

I’ve made the change to daemon.conf, about to restart and try it.

And it worked!

Just change this line in /etc/pulse/daemon.conf

; default-sample-channels = 2

to this:

default-sample-channels = 6

Alfresco

Going to have a play around with an open-source collaboration and content management solution called Alfresco. It’s supposed to be an alternative to Sharepoint, and has commercial and community (called Labs) versions.

First off, download the installer (I’m chucking on 3.1) http://wiki.alfresco.com/wiki/Labs_3_Final_download_files

Detailed installation/configuration instructions are here (PDF)
There’s also a more detailed guide to installing it on Ubuntu here.

I’ve done a vanilla 8.04 Server build (VM), and setup a static IP, software sources and openssh-server. I’m doing this stuff over an ssh terminal session.

1. Copy the installer to the local system (I’ve copied it to /home/Alfresco)

2. Install a bunch of stuff with:
apt-get install imagemagick mysql-server 'openoffice.org-headless' xvfb swftools sun-java6-jdk sun-java6-jre nfs-common portmap There’s a bit there, about 00MB, so you may want to grab a coffee depending on your download speed. Oh, and you’ll need to setup the MySQL password, and agree to give Sun your first-born for using Java.

3. Now the fun bit - install!
chmod 777 Alfresco-Labs-3Stable-Linux-x86-Install
./Alfresco-Labs-3Stable-Linux-x86-Install
Just leave stuff on defaults.

4. cd /opt/Alfresco
pico /opt/Alfresco/alfresco.sh
edit the following:
ALF_HOME=@@ALFRESCO_DIR@@
to
ALF_HOME=/opt/Alfresco

and

export JAVA_HOME="@@JAVA_HOME@@"
to
export JAVA_HOME="/usr/lib/jvm/java-6-sun-1.6.0.07"

(You’ll need to check that these paths are correct for your setup)

5. run pico /opt/Alfresco/virtual_alf.sh and do the same
6. Test MySQL is running: mysql -u root -p
7. Type exit
8. Add Alfresco user to MySQL mysql -p < /opt/Alfresco/extras/databases/mysql/db_setup.sql
9. Check the database is there:
mysql -p

show databases;

you should get

+--------------------+
| Database |
+--------------------+
| information_schema |
| alfresco |
| mysql |
+--------------------+
3 rows in set (0.00 sec)

Now type
quit

10. Change settings from HSQL to MySQL
cd /opt/Alfresco/tomcat/shared/classes/alfresco/extension/
pico custom-repository.properties
Change the dir.root to the absolute path of the data folder:
dir.root=/opt/Alfresco/alf_data

Add comments to HSQL connection options Remove comments from MySQL connection options So it looks like below:

.....
# Derby connection
#
#db.driver=org.apache.derby.jdbc.EmbeddedDriver
#db.url=jdbc:derby:alf_data/derby_data/alfresco;create=true
#
# HSQL connection
#
#db.driver=org.hsqldb.jdbcDriver
#db.url=jdbc:hsqldb:file:alf_data/hsql_data/alfresco;ifexists=true;shutdown=true;
#
# MySQL connection (This is default and requires mysql-connector-java-5.0.3-bin.jar, which ships with the Alfresco server)
#
db.driver=org.gjt.mm.mysql.Driver
db.url=jdbc:mysql://localhost/alfresco
......

11. Now we need to edit another file:
pico custom-hibernate-dialect.properties

Make looky like this:
.......
#
# Derby dialect
#
#hibernate.dialect=org.hibernate.dialect.DerbyDialect
#
# HSQL dialect
#
#hibernate.dialect=org.hibernate.dialect.HSQLDialect
#
# MySQL dialect (default)
#
hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect
#
# PostgreSQL dialect
#
......

12. Start the site:
/opt/Alfresco/alfresco.sh start

and browse to the site:
http://192.168.0.1:8080/share

/opt/Alfresco/virtual_alf.sh start

13. Set it to start automatically:

This will start alfresco when the server boots up The code was from http://blog.khax.net/2009/02/26/alfresco-setup-in-ubuntu-810-with-git/

create a file

pico initialize.sh

Add these lines

#!/bin/sh
ALF_HOME=/opt/Alfresco
echo "Creating init.d links"
ln -s $ALF_HOME/alfresco.sh /etc/init.d/alfresco
ln -s $ALF_HOME/virtual_alf.sh /etc/init.d/virtual_alf
update-rc.d alfresco defaults
ln -s $ALF_HOME/alfresco.sh /etc/init.d/alfresco
ln -s $ALF_HOME/virtual_alf.sh /etc/init.d/virtual_alf
update-rc.d alfresco defaults
update-rc.d virtual_alf defaults

Lets make it executable

chmod 777 initialize.sh

Run it

./initialize.sh

Reboot and see what happens.


Mine is up and running now, and it’s time to have a play around. This is borrowed VERY heavily from http://wiki.alfresco.com/wiki/Installing_Alfresco_Lab_3_Stable_on_Ubuntu_8.10, I’ve just rewritten some parts but this is basically what I’ve followed. My install is on 8.04.

Exporting Blogsome

June 13, 2009

One thing which has been on my mind recently, is backing up this Blog. I’ve got a lot of stuff on here I don’t want to lose, and the fact that I was getting random database errors this afternoon didn’t fill me with confidence.

Anyhoo, backing up Wordpress usually isn’t too much of an ordeal, except I obviously don’t have access to all the Good Stuff in the back-end of Blogsome’s setup. And from having a look through the forums, it looks like there’s a few solutions out there (none of which are very easy).

I found this page, which has what looks like a pretty nifty command you can use to basically do a static dump of a site to HTML files. So here ’tis:

wget -k -m -r http://url

I’ve run it on mine, so at least I have all the test from the site to keep for a rainy day.