<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>hartvig.de &#187; T60</title>
	<atom:link href="http://hartvig.de/category/t60/feed/" rel="self" type="application/rss+xml" />
	<link>http://hartvig.de</link>
	<description></description>
	<lastBuildDate>Mon, 19 Jul 2010 17:33:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Howto : Resume a failed copy command where it left off</title>
		<link>http://hartvig.de/2008/howto-resume-a-failed-copy-command-where-it-left-off/</link>
		<comments>http://hartvig.de/2008/howto-resume-a-failed-copy-command-where-it-left-off/#comments</comments>
		<pubDate>Mon, 18 Aug 2008 04:12:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[T60]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[n800]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://hartvig.de/?p=32</guid>
		<description><![CDATA[Currently, file copying utilities such as cp, scp, rsync etc. are not able to resume where they left off after a failed copy operation. In this article, a solution is provided using the utility dd to pick up where cp left off. Read on for more. Installation To install recp, type the following commands in [...]]]></description>
			<content:encoded><![CDATA[<p>Currently, file copying utilities such as <em>cp, scp, rsync</em> etc. are not able to resume where they left off after a failed copy operation. In this article, a solution is provided using the utility <em>dd</em> to pick up where <em>cp</em> left off. Read on for more.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://www.hartvig.de/files/images/nova.png" alt="" width="600" height="294" /></p>
<p><span id="more-32"></span><br />
<strong>Installation</strong><br />
To install <em>recp, t</em>ype the following commands in a terminal</p>
<pre class="prettyprint">wget http://www.hartvig.de/files/recp
mv recp ~/bin/
chmod +x ~/bin/recp</pre>
<p><strong>Usage</strong><br />
Lets assume, that you have tried to copy file1 to file2 with the command</p>
<pre class="prettyprint">cp file1 file2</pre>
<p>and that the copying process has somehow been interrupted. Now, you can simply resume the copying with the command</p>
<pre class="prettyprint">recp file1 file2</pre>
<p><strong>Issues</strong><br />
Please be aware, that since the script uses <em>dd</em> to continue copying it is both processor intensive and slow.</p>
<p><strong>Code </strong></p>
<pre class="prettyprint">#!/bin/bash

#set -x

if [ $# -ne 2 ]
then
	echo $0: Usage: $0 original copy
	exit 1
fi

# We need some more meaningful names.
ORIGINAL="$1"
COPY="$2"

if [ ! -f "$ORIGINAL" ]
then
	# ORIGINAL wasn't found.
	echo $0: "$ORIGINAL": No such file
	exit 1
fi

# Calculate the number of bytes to skip before we start copying.
if [ -f "$COPY" ]
then
	# This is a continuation of earlier, interrupted copy.

	WC_OUTPUT=$(wc --bytes "$COPY")

	# Since wc pads its output with spaces making it hard to reliably
	# parse, we have to do a little hack job:

	# Make sure there's at least one space at the beginning.
	WC_OUTPUT=" $WC_OUTPUT"

	# Sqeeze out excess spaces, making the size the second field.
	SKIP_BYTES=$(echo "$WC_OUTPUT" | tr -s ' ' | cut -d' ' -f2)
else
	# This is the first attempt at copying--there's no COPY yet.
	SKIP_BYTES=0
fi

# Do the actual copying.
dd if="$ORIGINAL" of="$COPY" conv=notrunc bs=1 skip="$SKIP_BYTES" seek="$SKIP_BYTES"</pre>
<p><strong>Credits:</strong><br />
Forum post on <a href="http://www.linuxquestions.org/questions/linux-newbie-8/how-to-resume-failed-copy-cp-command-where-it-left-off-183092/">inuxquestions.org</a></p>
]]></content:encoded>
			<wfw:commentRss>http://hartvig.de/2008/howto-resume-a-failed-copy-command-where-it-left-off/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
