<?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>Retiffy Developers &#187; ubuntu</title>
	<atom:link href="https://dev.retiffy.com/tag/ubuntu/feed/" rel="self" type="application/rss+xml" />
	<link>https://dev.retiffy.com</link>
	<description></description>
	<lastBuildDate>Thu, 11 Apr 2013 07:11:07 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Distribute backups to local machines</title>
		<link>https://dev.retiffy.com/2013/04/11/distribute-backups-to-local-machines/</link>
		<comments>https://dev.retiffy.com/2013/04/11/distribute-backups-to-local-machines/#comments</comments>
		<pubDate>Thu, 11 Apr 2013 07:06:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://dev.retiffy.com/?p=126</guid>
		<description><![CDATA[If you are a team as ours you are probably working remotely, with laptops, anywhere you can, anytime you can. This mean that all of our machines are &#8220;on the cloud&#8221;, they do run, scale and backup entirely automatically. But&#8230;]]></description>
				<content:encoded><![CDATA[<p>If you are a team as ours you are probably working remotely, with laptops, anywhere you can, anytime you can. This mean that all of our machines are &#8220;on the cloud&#8221;, they do run, scale and backup entirely automatically.</p>
<p>But what if you want to add one more line of defense &#8211; copying the backups locally to your machine from time to time. In this way even if in sequence of unlikely and strange events that corrupt your remote machines, you would have a local backup of your important information. But as in our case most of the time we forget to do a copy to a local machine. That&#8217;s why I would like to make it automatic.</p>
<p>What we are currently doing is copying a backup from remote to local every time your machine starts its Internet interface. And yes, this would would not scale for GB backups. But we are still not there.</p>
<p>This is the script:</p>
<blockquote><p>#! /bin/sh</p>
<p># Copies production_backup on this machine</p>
<p># This script should be copied at /etc/network/if-up.d/. In this way everytime the network starts a backup would be made<br />
export REPOSITORY=/home/kireto/robopartans/rbp.cm<br />
export USER_WITH_ACCESS=kireto</p>
<p>&nbsp;</p>
<p>echo &#8220;Starting script:&#8221; &gt;&gt; /tmp/production_backup_copy.log<br />
set -e</p>
<p>&nbsp;</p>
<p># Don&#8217;t bother when lo is configured.<br />
if [ "$IFACE" = lo ]; then<br />
exit 0<br />
fi</p>
<p>&nbsp;</p>
<p>#~ # Only run from ifup.<br />
if [ "$MODE" != start ]; then<br />
exit 0<br />
fi</p>
<p>&nbsp;</p>
<p>FILE=&#8221;production_backup$(date +&#8217;%Y_%m_%d&#8217;).sql.gz&#8221;<br />
LOCAL_PATH=&#8221;$REPOSITORY/$FILE&#8221;<br />
REMOTE_PATH=&#8221;\&#8221;/var/jenkins/jobs/Production\\ backup/workspace/$FILE\&#8221;"</p>
<p>if [ -f $LOCAL_PATH ]; then<br />
echo &#8220;File exists locally&#8221; &gt;&gt; /tmp/production_backup_copy.log<br />
exit 0<br />
fi</p>
<p>&nbsp;</p>
<p>sudo su &#8211; $USER_WITH_ACCESS -c &#8220;cd $REPOSITORY; scp root@elvis:$REMOTE_PATH .&#8221;<br />
echo &#8220;Pulling at: $(date +&#8221;%D %T&#8221;)&#8221; &gt;&gt; /tmp/production_backup_copy.log</p>
<p>exit 0</p></blockquote>
<p>This script is then added at</p>
<blockquote><p>/etc/network/if-up.d</p></blockquote>
<p>Now we have a distributed backup system, where simultaneous fail of all the machines and processes is impossible (except if someone starts a earth big <a href="http://en.wikipedia.org/wiki/Electromagnetic_pulse">Electromagnetic impulse</a>)</p>
]]></content:encoded>
			<wfw:commentRss>https://dev.retiffy.com/2013/04/11/distribute-backups-to-local-machines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delayed_job should be restarted on production build</title>
		<link>https://dev.retiffy.com/2013/03/25/delayed_job-should-be-restarted-on-production-build/</link>
		<comments>https://dev.retiffy.com/2013/03/25/delayed_job-should-be-restarted-on-production-build/#comments</comments>
		<pubDate>Mon, 25 Mar 2013 13:37:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[delayed_job]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://dev.retiffy.com/?p=113</guid>
		<description><![CDATA[Yes, it sounds obvious but it took me some time to figure that out. We were working on the campaigns downloads in Retiffy. This means generating a PDF for every certificate and then concatenating them into a single PDF and&#8230;]]></description>
				<content:encoded><![CDATA[<p>Yes, it sounds obvious but it took me some time to figure that out.</p>
<p>We were working on the campaigns downloads in Retiffy. This means generating a PDF for every certificate and then concatenating them into a single PDF and sending the link to the user. Now the problem is that this is done in a delayed_job and if you change the production databases and code without restarting delayed_job, the job preformed at a delay are still using the old code.</p>
<p>We haven`t dig deep enough to understand the internals and whether we could fix it in another way. Currently we are searching for the best solution to restart delayed_job on building production.</p>
<p>This is the initial source of the Ubuntu service that we have come up with. Hope it could help you. We will continue working on it with for restart and stop.</p>
<p>#!/bin/bash<br />
# Delayed job for Retiffy production<br />
# acts as startup service.<br />
# USAGE: start<br />
case &#8220;$1&#8243; in<br />
start)<br />
echo &#8220;Starting Delayed_job for Retiffy Production&#8221;<br />
RAILS_ENV=production<br />
export RAILS_ENV<br />
start-stop-daemon &#8211;start &#8211;pidfile /var/run/delayed_job.pid &#8211;make-pidfile &#8211;background &#8211;chuid www-data &#8211;exec /production/script/delayed_job &#8212; restart -i 2 || return 2<br />
;;</p>
<p>esac<br />
exit 0</p>
]]></content:encoded>
			<wfw:commentRss>https://dev.retiffy.com/2013/03/25/delayed_job-should-be-restarted-on-production-build/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
