Home > admin-stuff > Resume rsync transfer after SSH connection crash

Resume rsync transfer after SSH connection crash

Fri May 15 2009 02:00:00 GMT+0200 (Central European Summer Time)

Are you using SSH for your secure maintenance of your servers? - Sure.

Do you copy files with SCP between hosts? - Most likely.

Is there a need to transfer big files over slow and unreliable network connections (*)? - Could be.

Can SCP resume a download after the connection crashed? - No.

So why not simply use rsync over SSH for your file transfer. A minor drawback is, that unless you set up a rsync daemon (not appropriate for my case) you have to call rsync manually. Sadly rsync doesn't offer something like "automatic retry in case of a connection failure". (**)

Good for us, because now it's tool time again; a single bash script does the trick:

#!/bin/sh 
# reliable file transfer

# try rsync for x times 
I=0 
MAX_RESTARTS=5 
LAST_EXIT_CODE=1 
while [ $I -le $MAX_RESTARTS ] 
do 
	I=$(( $I + 1 )) 
	echo $I. start of rsync 
	rsync -av --partial --progress -e "ssh" x-ian@x-ian.net:~/MY_BIG_FILE . 
	LAST_EXIT_CODE=$? 
	if [ $LAST_EXIT_CODE -eq 0 ]; then 
		break 
	fi 
done

# check if successful 
if [ $LAST_EXIT_CODE -ne 0 ]; then 
	echo rsync failed for $I times. giving up. 
else 
	echo rsync successful after $I times. 
fi 

Ah, just a sidenote as I always forget the syntax: If you need to remote execute a command via SSH with variables from your local shell, take this:

CMD="test -e M\_BIG\_FILE || cp MY\_BIG\_FILE \`hostname -s\`-MY\_BIG\_FILE" 
ssh x-ian@x-ian.net $CMD 

--

(*) If you only have an unstable satellite link, even 150 MB are way too big. (**) Make sure that you actually test over the network; using rsync with source and destination files on the same system deactivates the delta-calculation algorithm.

Testing Webapps with multiple browsers

Wed May 13 2009 02:00:00 GMT+0200 (Central European Summer Time)

Developing web applications can be fun and hard almost at the same time.

But when it comes down to testing, it can be a ....

Sure every developer has his favorite environment and develops against it. But his special browser is just a part of the big picture and there are way to many different browsers and versions out there in the wild. Of course you know them all:

  • Internet Explorer [ 6 | 7 | 8 with Compatibility View | 8 ]
  • FireFox [2 | 3 ]
  • Safari [ 3 | 4 ]
  • Chrome
  • Opera

And those are only the traditional desktop browsers for MacOS, Win and Linux. (Personally I assume, that one browser behaves almost the same on different OS when it comes to the programming model. But this is not necessarily true for layout issues). Note that this list totally ignores the growing mobile market. I don't know yet how to deal with them...

It will get even ridiculous if you could only install one version of a browser at the same time. Yes, IE - most credits go to you! There are some hacks out there to install the Internet Explorer in different versions on one system.

In the past I've simply virtualized my system and got one image for every single browser. Worked, but it always felt like "shooting cannons to sparrows". There is quite some overhead involved to install and actually fire up the VM image.

Why not simply virtualize the browser? That's exactly what Xenocode is doing. Download, run and test. Nice. The seamlessly network integration even make those things like local proxy servers work.

--

January 21st, 2010 at 17:31 | #1Reply | Quote

maybe https://browserlab.adobe.com/index.html is worth a try too…

Develop with Firefox

Mon May 11 2009 02:00:00 GMT+0200 (Central European Summer Time)

What is your favorite environment to develop new web applications?

Currently I think there is no way around good ol' Firefox. Not because of the browser, but more because of all those addons. It took me some time to find my configuration. Here it is:

But too bad, I'm too lazy to describe them all. Anyway you have to get comfortable with your own list. What's on it?

Swap Lastname with Firstname in Outlook

Fri May 01 2009 02:00:00 GMT+0200 (Central European Summer Time)

Even my [ of course way too old, grandpa-style, ugly, quite unsexy, and nothing close to a nerd gadget ] mobile phone Nokia 6230 offers a PC sync. OK. They were supposed to offer this even in the last millennium. But ever since then I was struggling with it. Not even with a real day-to-day sync but just with a one-time copy operation of my contacts from my PC to the phone. Surely, if I only had/have a Mac. But life is never easy and you should always challenge yourself...

But why on earth is Nokia only offering one entry for a combined name field. In digits: 1, in letters again: ONE. But even more why on earth am at least I not able to put my Outlook contacts in the "Lastname Firstname" order to the phone. The PC Suite seems just to know it better and doesn't let me. Therefore an alphabetic sort on the phone just shows of all the firstnames first. Crap and I need another solution.

So as I'm a developer I was refusing to simply look for already working solutions or even spend money. I had to do it the do-it-yourself way (for sure hundreds must have done this before).

So here is a small Outlook macro which takes all of your entries in the address book and places them in a new outlook address book called NokiaAddressBook. There it simply swaps lastname with firstname and I get my "Lastname Firstname" style. Stupid ugly, but also stupid simple.

Too bad my Nokia broke recently and now I switched to a Sony Ericsson.

PS1: This solution was heavily influenced. Thanks! PS2: If you do the sync, close the Nokia Phone browser as it seems to block to connection of the PC Suite to your phone. PS3: The Nokia Phone Browser supports an import/export of vCards. But (not surprisingly) Outlook does not. Another but: The standard windows address reads vCards. So import vCards first to the Windows addressbook and from there to Outlook...

Network (HTTP) speed simulator

Thu Apr 23 2009 02:00:00 GMT+0200 (Central European Summer Time)

If you're seriously developing a webapp, sooner than later one of your clients will come with some Internet Explorer 6 related complains. Still in 2009, the year of the IE Death march. So what to do if they say: With IE6 is takes 3x longer to load the page than with _any other browser_?

But even if it is not the IE6, you still might wonder how your app behaves with different connection speeds. There are some (windows) applications out there, which try to simulate different network connections. There must be others, but I've found Netlimiter and Speed Simulator as out-of-the-box solutions. But Netlimiter is not free and Speed Simulator seems to have some problems with certain requests (AJAX, forwards, ... who knows).

When it comes to HTTP-related things, why not using Squid as the de-facto standard for Proxy Servers?

Installing Squid is not as difficult as it may sound, even under Windows. Just make sure that the Delayed Pools Feature is enabled.

For your personal development you can leave all of the default configs in the squid.conf, except those:

1. # allow all requests 
acl all src 0.0.0.0/0.0.0.0 
http_access allow all 
icp_access allow all

2. # delayed pools 
delay_pools 1 
delay_class 1 1 
delay_access 1 
allow all delay_parameters 1 4000/4000 
# 64000 = 64 kbytes = 512 kbits 
#  8000 =  8 kbytes =  64 kbits 
#  4000 =  4 kbytes =  32 kbits

To change the connection speed, simply tweak the values for delay_parameters e.g. to 64000/64000.

And if your are using Firefox as one of your development browsers, simply install the SwitchProxy Addon. This allows you to quickly switch between preconfigured proxy settings on-the-fly.

[And if you really what to go "pro", set-up multiple instances of Squid with different connection speeds, provide their services under different ports, and create different proxy configs for SwitchProxy. Then you don't even have to modify the squid.conf every time you want to switch the speed.]

Everyone can start a business

Tue Apr 21 2009 02:00:00 GMT+0200 (Central European Summer Time)

Even his brother. So why not me?

Granted. I'm not the only head behind firstprinciplesmanagement.com, it is still in beta, and under construction at best,  but hey:

You have to start somewhere.

So if this flies off, then you might find more (personal) posts here.

Oh, and yes: Just another side built on Ruby on Rails.

Kategorie Tourenbuch

Sun Apr 19 2009 02:00:00 GMT+0200 (Central European Summer Time)

Was kommt eigentlich in ein Tourenbuch?

  • Muss eine Tour anstrengend sein?
  • Gefährlich?
  • Möglichst viele Höhenmeter?
  • Als bestimmte Sportart ausgeführt?

Also, ich weiss ich nicht und das ist wohl auch egal. Ich sammel einfach alles, was mir (vor allem in den Bergen) Spass gemacht hat. Hauptsächlich weil mein Gedächtnis zu lückenhaft ist, um mir dies alles zu merken.

Großer Daumen im Schneeschuh-Stil

Sun Apr 19 2009 02:00:00 GMT+0200 (Central European Summer Time)

OK, heute war keiner so blöd, mit Schneeschuhen zu stapfen.

Alle waren mit Tourenski auf den Großen Daumen unterwegs. Alle?

Nein! Nicht alle.

Bloss einer kam auf die Idee, nur mit Schneeschuhen die 2280 m zu erklimmen. Dafür habe ich immerhin "by fair means" die 15 km Anfahrt mit dem Radel und den Schneeschuhen auf dem Rücken zurücklegt.

It's about to start

Sat Apr 18 2009 02:00:00 GMT+0200 (Central European Summer Time)

A new blog for my simple thoughts; regarding my work and (some parts of) my private activities. Let's see if and how it grows.

Oh, and yes. Even though this is the very first post, I will add some entries with older dates. Just for me to not forget them. I know that I will fake the history, but hey, who cares?

--

May 1st, 2009 at 18:35 | #1Reply | Quote

…lonely comment…

Immer mal wieder "Großer Feldberg"

Tue Feb 24 2009 01:00:00 GMT+0100 (Central European Standard Time)

Dem Großen Feldberg gebürt als der "Summit" meiner ehemaligen Hausberge hier ein eigener Abschnitt.

Im Sommer wie im Winter; zu Fuss, mit dem Rad oder auch im Auto ist man oben um runter zu gucken. U.a. auch weil hier wichtige Dinge entschieden und verarbeitet wurden.

Comments are closed.