<?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>Musings of an Apple Systems Administrator &#187; backup</title>
	<atom:link href="http://www.jonsblog.org/tag/backup/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jonsblog.org</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sun, 01 Aug 2010 05:56:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>III Syncing a failover website : Scheduling the sync</title>
		<link>http://www.jonsblog.org/2010/05/31/iii-syncing-a-failover-website-scheduling-the-sync/</link>
		<comments>http://www.jonsblog.org/2010/05/31/iii-syncing-a-failover-website-scheduling-the-sync/#comments</comments>
		<pubDate>Mon, 31 May 2010 22:29:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[OSX System Administration]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[cronjob]]></category>
		<category><![CDATA[schedule]]></category>

		<guid isPermaLink="false">http://www.jonsblog.org/?p=147</guid>
		<description><![CDATA[So now we have our backup script, we have our secure SSH tunnel between the two servers and we have successfully synced our two databases and our files. Now we just have to schedule this task so that we do not have to manually run this each time we need to synchronize our systems. On [...]]]></description>
			<content:encoded><![CDATA[<p>So now we have our backup script, we have our secure SSH tunnel between the two servers and we have successfully synced our two databases and our files. Now we just have to schedule this task so that we do not have to manually run this each time we need to synchronize our systems. On Mac OSX Servers you have two options you can use Crontab and run a Cronjob, or you can use Launchd. If your running a Linux server then your pretty limited to just a Cronjob. We will talk about both types of scheduling methods and which one makes the best sense for your setup. </p>
<p>Crontab is one of the longest lasting scheduling daemons around, its part of any linux / unix system and uses a file that will trigger a script at a specific time at specific intervals. Cron can be pretty amazing but pretty daunting too if you are unsure about how to use cron, I recommend starting out easy and using this GUI for Mac OSX called <a href="http://code.google.com/p/cronnix/">Cronnix</a>.</p>
<p><a href="http://code.google.com/p/cronnix/">Cronnix</a> is a great tool because it lets you modify, save and create crontab cronjobs in a very easy to use interface. Before <a href="http://code.google.com/p/cronnix/">Cronnix</a> you basically had to use the VI editor in order to edit the crontab file manually which did not always prove successful. Once your ready to make your first schedule then you need to know what time or at what intervals you want the backup to run. I had my backup script run at midnight every-night so my crontab looked like this.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">0</span> <span style="color: #000000;">0</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>my<span style="color: #000000; font-weight: bold;">/</span>sync<span style="color: #000000; font-weight: bold;">/</span>script.sh</pre></td></tr></table></div>

<p><span id="more-147"></span><br />
Here are some other popular crontab examples that might give you some greater insight and understanding on the whole cronjob scheduling schema.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">0</span> <span style="color: #000000;">0</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span>          <span style="color: #660033;">--</span> midnight every day
<span style="color: #000000;">0</span> <span style="color: #000000;">0</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000;">1</span>-<span style="color: #000000;">5</span>        <span style="color: #660033;">--</span> midnight every weekday
<span style="color: #000000;">0</span> <span style="color: #000000;">0</span> <span style="color: #000000;">1</span>,<span style="color: #000000;">15</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span>       <span style="color: #660033;">--</span> midnight on 1st and 15th
                      of month
<span style="color: #000000;">0</span> <span style="color: #000000;">0</span> <span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000;">5</span>          <span style="color: #660033;">--</span> midnight on 1st of month
                      and every Friday</pre></td></tr></table></div>

<p>The second method for scheduling tasks on a Mac OSX Server platform is Launcd. This is the timer system that Apple has written and sanctioned as being the best way to schedule tasks, the reason is that unlike a cronjob where if you want to pause the job, you must remove it from the system entirely and then re-enter it when you want it to resume. With launchd you can unload / or load schedules to run at startup or on regularly scheduled intervals. I would be lying if I told you I was a launchd master, but I do like the advantages that launchd has to offer. </p>
<p>While getting my script up and running I used <a href="http://www.macresearch.org/tutorial_backups_with_launchd">This tutorial</a> to get me started. The launchd file below is what I used in order to get my backup scheduled. In order to install your launchd file place it in one of these locations.</p>
<p>/System/Library/LaunchDaemons (admin level system daemons)<br />
/System/Library/LaunchAgents (admin level user agents)</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
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;</span> ? xml <span style="color: #007800;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #007800;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span> ? <span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;!</span>DOCTYPE plist PUBLIC <span style="color: #ff0000;">&quot;-//Apple Computer//DTD PLIST 1.0//EN&quot;</span> \ <span style="color: #ff0000;">&quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;</span>dict<span style="color: #000000; font-weight: bold;">&gt;</span>
        <span style="color: #000000; font-weight: bold;">&lt;</span>key<span style="color: #000000; font-weight: bold;">&gt;</span>Label<span style="color: #000000; font-weight: bold;">&lt;/</span>key<span style="color: #000000; font-weight: bold;">&gt;</span>
        <span style="color: #000000; font-weight: bold;">&lt;</span>string<span style="color: #000000; font-weight: bold;">&gt;</span>com.macresearch.backup<span style="color: #000000; font-weight: bold;">&lt;/</span>string<span style="color: #000000; font-weight: bold;">&gt;</span>
        <span style="color: #000000; font-weight: bold;">&lt;</span>key<span style="color: #000000; font-weight: bold;">&gt;</span>LowPriorityIO<span style="color: #000000; font-weight: bold;">&lt;/</span>key<span style="color: #000000; font-weight: bold;">&gt;</span>
        <span style="color: #000000; font-weight: bold;">&lt;</span>true<span style="color: #000000; font-weight: bold;">/&gt;</span>
        <span style="color: #000000; font-weight: bold;">&lt;</span>key<span style="color: #000000; font-weight: bold;">&gt;</span>Program<span style="color: #000000; font-weight: bold;">&lt;/</span>key<span style="color: #000000; font-weight: bold;">&gt;</span>
        <span style="color: #000000; font-weight: bold;">&lt;</span>string<span style="color: #000000; font-weight: bold;">&gt;/</span>Users<span style="color: #000000; font-weight: bold;">/</span>gohara<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>Scripts<span style="color: #000000; font-weight: bold;">/</span>backup.sh<span style="color: #000000; font-weight: bold;">&lt;/</span>string<span style="color: #000000; font-weight: bold;">&gt;</span>
        <span style="color: #000000; font-weight: bold;">&lt;</span>key<span style="color: #000000; font-weight: bold;">&gt;</span>ProgramArguments<span style="color: #000000; font-weight: bold;">&lt;/</span>key<span style="color: #000000; font-weight: bold;">&gt;</span>
        <span style="color: #000000; font-weight: bold;">&lt;</span>array<span style="color: #000000; font-weight: bold;">&gt;</span>
                <span style="color: #000000; font-weight: bold;">&lt;</span>string<span style="color: #000000; font-weight: bold;">&gt;</span>backup.sh<span style="color: #000000; font-weight: bold;">&lt;/</span>string<span style="color: #000000; font-weight: bold;">&gt;</span>
        <span style="color: #000000; font-weight: bold;">&lt;/</span>array<span style="color: #000000; font-weight: bold;">&gt;</span>
        <span style="color: #000000; font-weight: bold;">&lt;</span>key<span style="color: #000000; font-weight: bold;">&gt;</span>WatchPaths<span style="color: #000000; font-weight: bold;">&lt;/</span>key<span style="color: #000000; font-weight: bold;">&gt;</span>
        <span style="color: #000000; font-weight: bold;">&lt;</span>array<span style="color: #000000; font-weight: bold;">&gt;</span>
        <span style="color: #000000; font-weight: bold;">&lt;</span>string<span style="color: #000000; font-weight: bold;">&gt;/</span>Volumes<span style="color: #000000; font-weight: bold;">&lt;/</span>string<span style="color: #000000; font-weight: bold;">&gt;</span>
        <span style="color: #000000; font-weight: bold;">&lt;/</span>array<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;/</span>dict<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;/</span>plist<span style="color: #000000; font-weight: bold;">&gt;</span></pre></td></tr></table></div>

<p>Once you have your launchd file installed you must register the launchd file with your system by running</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">  launchctl load ~<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>LaunchAgents</pre></td></tr></table></div>

<p>Then issue</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"> launchctl list</pre></td></tr></table></div>

<p>Then you should see something like this</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>Voyager:~<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>Scripts<span style="color: #7a0874; font-weight: bold;">&#93;</span> gohara<span style="color: #000000; font-weight: bold;">%</span> launchctl list
com.macresearch.backup</pre></td></tr></table></div>

<p>for my sync script I chose to use a crontab, because my knowledge of launchd is limited and my experience with cronjobs is more extensive I found that adding a cronjob was faster, quicker and more efficient for permanent scheduled items on my servers. I would love to get your feedback however and learn more about launchd from you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jonsblog.org/2010/05/31/iii-syncing-a-failover-website-scheduling-the-sync/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>10.6.2 Dovecot Mail Backups</title>
		<link>http://www.jonsblog.org/2010/01/24/10-6-2-dovecot-mail-backups/</link>
		<comments>http://www.jonsblog.org/2010/01/24/10-6-2-dovecot-mail-backups/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 00:08:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Mail Server]]></category>
		<category><![CDATA[OSX Server Configuration]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[dovecot]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://www.jonsblog.org/?p=33</guid>
		<description><![CDATA[Before migrating to 10.6 Server we were running our entire mailstore on the 10.5.8 platform. Say what you will about Leopard, once we had it set up correctly it ran fine. We migrated because of the greater benefits of Dovecot over Cyrus. Many of the other features intriqued us as well such as the improved [...]]]></description>
			<content:encoded><![CDATA[<p>Before migrating to 10.6 Server we were running our entire mailstore on the 10.5.8 platform. Say what you will about Leopard, once we had it set up correctly it ran fine. We migrated because of the greater benefits of Dovecot over Cyrus. Many of the other features intriqued us as well such as the improved Wiki server and iCal server. However we were really excited about Dovecots ability to repair itself basically doing away with the need to ever have to rebuild a users mailbox.</p>
<p>The one great thing about 10.5.8 was the development of <a href="http://osx.topicdesk.com/content/view/41/41/">Mailbfr</a> this was an amazing script that would help you backup your entire mailstore, recover email accounts, repair quotas, and of course rebuild or repair the entire mail-store. This was an invaluable tool, however since switching we have had to come up with our own solution.</p>
<p>We tried at first to get RSYNC running however this did not work because we did not have the permission to copy the mailstore with the permissions in tact. The reason is that while the root account does have access to look at the mailstore the secondary user on the mailstore folder is the mail user itself. Without running the script as each user then its near impossible to use RSYNC to move the mailstore or to even perform a simple backup.<span id="more-33"></span></p>
<p>Our solution was to create a backup script that use SCP with SCP we were able to move our mail-store to another drive on the server. It copies the store over and it resets the permissions to the administrator account. This solution works very well however after some time with a large mailstore you will run out of space on the target volume. Unlike RSYNC which uses hard links to save space SCP creates a new copy of the mailstore each time it is run.</p>
<p>In order to save space on the backup volume the oldest 2 weeks worth of backed up email gets dumped to DVD and removed from the drive on a monthly basis. This is fine but not optimal. Here is a copy of the script that we use on our server.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> backup started daily backup <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #000000; font-weight: bold;">/</span>Volumes<span style="color: #000000; font-weight: bold;">/</span>EMAIL\ BACKUP<span style="color: #000000; font-weight: bold;">/</span>Backup<span style="color: #000000; font-weight: bold;">/</span>Logs<span style="color: #000000; font-weight: bold;">/</span>Backup_log.txt
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">scp</span> <span style="color: #660033;">-r</span> <span style="color: #000000; font-weight: bold;">/</span>Volumes<span style="color: #000000; font-weight: bold;">/</span>Mailstore-Location<span style="color: #000000; font-weight: bold;">/</span>spool <span style="color: #000000; font-weight: bold;">/</span>Volumes<span style="color: #000000; font-weight: bold;">/</span>EMAIL\ BACKUP<span style="color: #000000; font-weight: bold;">/</span>Email-Backups<span style="color: #000000; font-weight: bold;">/</span>$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>d<span style="color: #7a0874; font-weight: bold;">&#41;</span>-$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>m<span style="color: #7a0874; font-weight: bold;">&#41;</span>-$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>Y<span style="color: #7a0874; font-weight: bold;">&#41;</span>backup 
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> backup daily backup completed <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #000000; font-weight: bold;">/</span>Volumes<span style="color: #000000; font-weight: bold;">/</span>EMAIL\ BACKUP<span style="color: #000000; font-weight: bold;">/</span>Backup<span style="color: #000000; font-weight: bold;">/</span>Logs<span style="color: #000000; font-weight: bold;">/</span>Backup_log.txt</pre></td></tr></table></div>

<p>This will backup the mailstore and then log each time that it does so. To recover an email to the original mailstore is not as hard as it seems. Navigate to the backed up mailstore destination and match up the name of the folder to the users UID of which you want to recover. For example if the users UID is 7458-58713-952554-544226 then you would look for a folder with the same name. Once in the folder you can copy or look at individual email files. Find the ones or one that you need and copy it to the folder of the original mailstore. In order to do this you will have to use sudo. For example this is how you would restore the entire folder</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">scp</span> <span style="color: #660033;">-r</span> <span style="color: #ff0000;">&quot;Volumes/EMAIL\ BACKUP/Email-Backups/7458-58713-952554-544226/.*&quot;</span> <span style="color: #ff0000;">&quot;/Volumes/Mailstore-Location/spool/7458-58713-952554-544226/.*&quot;</span></pre></td></tr></table></div>

<p>Until <a href="http://osx.topicdesk.com/content/view/41/41/">Mailbfr</a> comes back for Dovecot this is how we are protecting ourself against the accidental loss of email. I am not saying that this is the best method it is simply the one we are using. If you have another solution that works bette than please let me know and share your own experience!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jonsblog.org/2010/01/24/10-6-2-dovecot-mail-backups/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
