<?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>Marius van Witzenburg &#187; Kill</title>
	<atom:link href="http://mariusvw.com/tag/kill/feed/" rel="self" type="application/rss+xml" />
	<link>http://mariusvw.com</link>
	<description>We fight for our survival, we fight!</description>
	<lastBuildDate>Tue, 27 Dec 2011 10:35:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to backup from a Western Digital Sharespace to another Sharespace</title>
		<link>http://mariusvw.com/2010/03/11/how-to-backup-from-a-western-digital-sharespace-to-another-sharespace/</link>
		<comments>http://mariusvw.com/2010/03/11/how-to-backup-from-a-western-digital-sharespace-to-another-sharespace/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 20:08:47 +0000</pubDate>
		<dc:creator>mariusvw</dc:creator>
				<category><![CDATA[BSD / Linux / Unix]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Daemon]]></category>
		<category><![CDATA[Disk]]></category>
		<category><![CDATA[HUP]]></category>
		<category><![CDATA[Kill]]></category>
		<category><![CDATA[Mail]]></category>
		<category><![CDATA[Rsync]]></category>
		<category><![CDATA[Sharespace]]></category>
		<category><![CDATA[Sync]]></category>
		<category><![CDATA[TERM]]></category>
		<category><![CDATA[WD]]></category>
		<category><![CDATA[Western DIgital]]></category>

		<guid isPermaLink="false">http://mariusvw.com/?p=1324</guid>
		<description><![CDATA[There is a newer version of this script available here. You might need this: How to enable SSH on a Western Digital ShareSpace For a script running from a FreeBSD server check this script. ~~~ Lately I've been busy with making a backup script to automate the backup of a WD Sharespace drive. This script [...]]]></description>
			<content:encoded><![CDATA[<p><strong>There is a newer version of this script available <a href="http://kitara.nl/2010/03/13/how-to-backup-from-a-western-digital-sharespace-to-another-sharespace-v2/">here</a>.</p>
<p>You might need this: <a href="http://kitara.nl/2011/06/30/how-to-enable-ssh-on-a-western-digital-sharespace/" title="How to enable SSH on a Western Digital ShareSpace" >How to enable SSH on a Western Digital ShareSpace</a></p>
<p>For a script running from a FreeBSD server check <a href="http://kitara.nl/2010/03/23/how-to-backup-from-a-western-digital-sharespace-to-another-sharespace-via-rsync-and-freebsd/">this</a> script.</strong><br />
~~~<br />
Lately I've been busy with making a backup script to automate the backup of a WD Sharespace drive.</p>
<p>This script has been made to backup between two Sharespace drives.</p>
<p>The script works quite simple. In a endless loop it keeps on running when you start it to the background with: <em>./backup.sh &#038;</em></p>
<p>It scans for the shares on your master drive and it will Rsync it to your slave drive on the share <em>backup</em>.</p>
<p>Put this script on your slave drive in /root/backup.sh</p>
<p>If you decide to modify this script please leave my name in the script.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #007800;">time</span>=<span style="color: #000000;">5</span>
<span style="color: #007800;">src_ip</span>=<span style="color: #ff0000;">&quot;192.168.3.3&quot;</span>
<span style="color: #007800;">log</span>=<span style="color: #ff0000;">&quot;/root/backup.log&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Written by Marius van Witzenburg</span>
<span style="color: #666666; font-style: italic;"># http://kitara.nl</span>
&nbsp;
<span style="color: #007800;">PATH</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin:<span style="color: #000000; font-weight: bold;">/</span>sbin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>sbin
<span style="color: #007800;">PID</span>=<span style="color: #007800;">$$</span>
cleanup<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #800000;">${log}</span>
    <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #007800;">$?</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
s_hup<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;n*** SIGHUP! Ignoring ***n&quot;</span>
    cleanup
    <span style="color: #666666; font-style: italic;">#exit $?</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
s_int<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-en</span> <span style="color: #ff0000;">&quot;n*** SIGINT! Exiting ***n&quot;</span>
    <span style="color: #c20cb9; font-weight: bold;">kill</span> <span style="color: #800000;">${JOB}</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #007800;">$?</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
s_term<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-en</span> <span style="color: #ff0000;">&quot;n*** SIGTERM! Exiting ***n&quot;</span>
    <span style="color: #c20cb9; font-weight: bold;">kill</span> <span style="color: #800000;">${JOB}</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #007800;">$?</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">trap</span> s_hup SIGHUP
<span style="color: #7a0874; font-weight: bold;">trap</span> s_int SIGINT
<span style="color: #7a0874; font-weight: bold;">trap</span> s_term SIGTERM
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Having a rest for the first run...&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #800000;">${log}</span>
<span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">30</span> <span style="color: #000000; font-weight: bold;">&amp;</span>
<span style="color: #007800;">JOB</span>=<span style="color: #007800;">$!</span>
<span style="color: #7a0874; font-weight: bold;">wait</span> <span style="color: #800000;">${JOB}</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Running backup...&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #800000;">${log}</span>
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #000000; font-weight: bold;">for</span> x <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #800000;">${src_ip}</span> <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-l</span> <span style="color: #000000; font-weight: bold;">/</span>shares<span style="color: #000000; font-weight: bold;">/|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;^d&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{ print $9 }'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #000000; font-weight: bold;">do</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-z</span> <span style="color: #800000;">${x}</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
        <span style="color: #000000; font-weight: bold;">then</span>
            <span style="color: #007800;">output</span>=<span style="color: #ff0000;">''</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #780078;">`expr ${x} : '(usb[0-9]-[0-9]share[0-9])'`</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
            <span style="color: #000000; font-weight: bold;">then</span>
                <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">&quot;/shares/<span style="color: #007800;">${x}</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
                <span style="color: #000000; font-weight: bold;">then</span>
                    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;USB Syncing '/shares/<span style="color: #007800;">${x}</span>' to '/shares/<span style="color: #007800;">${x}</span>'n&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span>
                    rsync <span style="color: #660033;">-qau</span> <span style="color: #660033;">--no-t</span> <span style="color: #660033;">--checksum</span> <span style="color: #660033;">--delete</span> <span style="color: #800000;">${src_ip}</span>:<span style="color: #000000; font-weight: bold;">/</span>shares<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${x}</span><span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">/</span>shares<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${x}</span><span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">&amp;</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #800000;">${log}</span> <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
                    <span style="color: #007800;">JOB</span>=<span style="color: #007800;">$!</span>
                    <span style="color: #7a0874; font-weight: bold;">wait</span> <span style="color: #800000;">${JOB}</span>
                    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;n<span style="color: #007800;">${JOB}</span> -- finished.nn&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #800000;">${log}</span>
                <span style="color: #000000; font-weight: bold;">else</span>
                    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;Skipping USB for '/shares/<span style="color: #007800;">${x}</span>'n&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #800000;">${log}</span>
                <span style="color: #000000; font-weight: bold;">fi</span>
            <span style="color: #000000; font-weight: bold;">else</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;Syncing '/shares/<span style="color: #007800;">${x}</span>' to '/shares/backup/<span style="color: #007800;">${x}</span>'n&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span>
                rsync <span style="color: #660033;">-qau</span> <span style="color: #660033;">--no-t</span> <span style="color: #660033;">--checksum</span> <span style="color: #660033;">--delete</span> <span style="color: #800000;">${src_ip}</span>:<span style="color: #000000; font-weight: bold;">/</span>shares<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${x}</span><span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">/</span>shares<span style="color: #000000; font-weight: bold;">/</span>backup<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${x}</span><span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">&amp;</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #800000;">${log}</span> <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
                <span style="color: #007800;">JOB</span>=<span style="color: #007800;">$!</span>
                <span style="color: #7a0874; font-weight: bold;">wait</span> <span style="color: #800000;">${JOB}</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;n<span style="color: #007800;">${JOB}</span> -- finished.nn&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #800000;">${log}</span>
            <span style="color: #000000; font-weight: bold;">fi</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
    <span style="color: #000000; font-weight: bold;">done</span>
    <span style="color: #007800;">message</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #800000;">${log}</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;From: noreply@kitara.nlnTo: info@kitara.nlnSubject: ShareSpace backup output.nn<span style="color: #007800;">${message}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>msmtp info<span style="color: #000000; font-weight: bold;">@</span>kitara.nl
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;Waiting for cycle (<span style="color: #007800;">${time}</span> minutes)...n&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #800000;">${log}</span>
    <span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">expr</span> <span style="color: #800000;">${time}</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000;">60</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #000000; font-weight: bold;">&amp;</span>
    <span style="color: #007800;">JOB</span>=<span style="color: #007800;">$!</span>
    <span style="color: #7a0874; font-weight: bold;">wait</span> <span style="color: #800000;">${JOB}</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Running cycle...&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #800000;">${log}</span>
<span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #666666; font-style: italic;"># EOF</span></pre></td></tr></table></div>

<p>Comments and donations are more than welcome <img src='http://mariusvw.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://mariusvw.com/2010/03/11/how-to-backup-from-a-western-digital-sharespace-to-another-sharespace/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

