<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>The UNIX way of life</title>
	<atom:link href="http://unixwayoflife.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://unixwayoflife.wordpress.com</link>
	<description></description>
	<lastBuildDate>Wed, 12 Nov 2008 23:01:50 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='unixwayoflife.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/7f0cc40edc882920f14efafa96b6f032?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>The UNIX way of life</title>
		<link>http://unixwayoflife.wordpress.com</link>
	</image>
			<item>
		<title>Automated WordPress.com Backup &#8211; Part 2</title>
		<link>http://unixwayoflife.wordpress.com/2008/11/12/automated-wordpress-com-backup-part2/</link>
		<comments>http://unixwayoflife.wordpress.com/2008/11/12/automated-wordpress-com-backup-part2/#comments</comments>
		<pubDate>Wed, 12 Nov 2008 17:04:28 +0000</pubDate>
		<dc:creator>unixwayoflife</dc:creator>
				<category><![CDATA[Perl scripts]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[automated backup]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[wordpress backup]]></category>
		<category><![CDATA[wordpress.com backup]]></category>

		<guid isPermaLink="false">http://unixwayoflife.wordpress.com/?p=24</guid>
		<description><![CDATA[Note: this post builds on Part 1, so read it first.
In my previous post I explained how to download the backup xml from the command line without a password prompt. An automated backup system should run of course automatically, so we need to automate it. It can be done with a cron job.
Cron is the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unixwayoflife.wordpress.com&blog=5385081&post=24&subd=unixwayoflife&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Note: this post builds on <a title="Part 1" href="http://unixwayoflife.wordpress.com/2008/11/08/automated-wordpress-com-backup/" target="_self">Part 1</a>, so read it first.</p>
<p>In my previous post<em> </em>I explained how to download the backup xml from the command line without a password prompt. An automated backup system should run of course automatically, so we need to automate it. It can be done with a cron job.</p>
<p><a title="Cron" href="http://en.wikipedia.org/wiki/Cron" target="_blank">Cron</a> is the name of program that enables unix users to execute commands or scripts (groups of commands) automatically at a specified time/date.</p>
<p>For a more comprehensive(but easy to understand) cron tutorial go to <a title="http://ubuntuforums.org/showthread.php?t=102625" href="http://ubuntuforums.org/showthread.php?t=102625" target="_self">http://ubuntuforums.org/showthread.php?t=102625</a>.</p>
<p>Here is how to do it:<br />
First make the perl file executable. Without that cron won&#8217;t run the script.</p>
<pre class="brush: css;"> chmod u+x  wordpress_backup.perl </pre>
<p>Cron is by default installed on most linux system, including ubuntu.<br />
There is a special format for entering cronjobs:</p>
<p>Minute Hour Day Month Day Task</p>
<p>Minute = Minute of the hour, 00 to 59. * Will indicate every minute<br />
Hour = Hour of the day in 24-hour format, 00 to 23. * Will indicate every hour<br />
Day = Day of the month, 1 to 31. * Will indicate every day<br />
Month = Month of the year, 1 to 12. * Will indicate every month<br />
Day = Day of the week, 3 chars &#8211; sun, mon, tue, &#8230; * Will indicate every day<br />
Task = The command you want to execute</p>
<p>Note: each of the above must be separated by at least 1 space.</p>
<p>Run the following command (it opens an editor usually nano or pico):</p>
<pre class="brush: css;">  crontab -e </pre>
<p>Copy&amp;paste the following two lines(change the time, email and path):</p>
<pre class="brush: css;">
MAILTO=YourEmail@example.com
03 20 * * * /path/to/script/wordpress_backup.perl </pre>
<p>For nano editor: CTRL+O  to save the file and  CTRL+X  to exit the file.</p>
<p>The above example will run /path/to/script/wordpress_backup.perl at 8:03 pm everyday.</p>
<p>To test the setup use current time +2 minutes and wait for the backup file to<br />
appear in the <span>$path_to_file </span>directory<span>. If it is there it works! You can also double check the file by manually downloading it and comparing the two files.<br />
</span></p>
<p>Note: always use absolute pathnames (such as &#8220;/files/home/user/filename&#8221;) to specify the script in crontab. This is also true for any local scripts you use within other scripts and for any system commands you use within the script you are running.</p>
<p>Some more examples:</p>
<p>How do I run a task at 6PM every night?</p>
<pre class="brush: css;">  00 18 * * * /command/to/execute </pre>
<p>How do I run a perl script at 2am every Sunday?</p>
<pre class="brush: css;">  00 02 * * sun /home/user/script.perl </pre>
<p>This solution isn&#8217;t perfect. It will run the backup script at given hour only when the pc is on at that time. It also backups the wordpress xml file(posts, comments, &#8230;) only.</p>
<p>In Part 3 I&#8217;ll show how to backup images and (maybe) how to run it on windows.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/unixwayoflife.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/unixwayoflife.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/unixwayoflife.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/unixwayoflife.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/unixwayoflife.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/unixwayoflife.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/unixwayoflife.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/unixwayoflife.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/unixwayoflife.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/unixwayoflife.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unixwayoflife.wordpress.com&blog=5385081&post=24&subd=unixwayoflife&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://unixwayoflife.wordpress.com/2008/11/12/automated-wordpress-com-backup-part2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">unixwayoflife</media:title>
		</media:content>
	</item>
		<item>
		<title>Automated WordPress.com Backup &#8211; Part 1</title>
		<link>http://unixwayoflife.wordpress.com/2008/11/08/automated-wordpress-com-backup/</link>
		<comments>http://unixwayoflife.wordpress.com/2008/11/08/automated-wordpress-com-backup/#comments</comments>
		<pubDate>Sat, 08 Nov 2008 21:09:00 +0000</pubDate>
		<dc:creator>unixwayoflife</dc:creator>
				<category><![CDATA[Perl scripts]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[backup script]]></category>
		<category><![CDATA[wordpress backup]]></category>
		<category><![CDATA[wordpress.com backup]]></category>

		<guid isPermaLink="false">http://unixwayoflife.wordpress.com/?p=3</guid>
		<description><![CDATA[Updated on 12 November 2008:  added Part2(how to setup cronjob).
I was going to write my first post on another topic, but then I realized that I&#8217;m not able to  backup this blog automatically. So I wrote a simple perl script. All it does is login, download the xml backup file and log off.
Although [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unixwayoflife.wordpress.com&blog=5385081&post=3&subd=unixwayoflife&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Updated on 12 November 2008:  added <a title="Part2" href="http://unixwayoflife.wordpress.com/2008/11/12/automated-wordpress-com-backup-part2/" target="_self">Part2</a>(how to setup cronjob).</p>
<p>I was going to write my first post on another topic, but then I realized that I&#8217;m not able to  backup this blog automatically. So I wrote a simple perl script. All it does is login, download the xml backup file and log off.</p>
<p>Although I created it specially for wordpress.com blogs it works with standard wordpress installations too.</p>
<p>This script has been tested on debian. It should work on any UNIX-like OS with perl. I think, it would also run on windows, with little or no modification.</p>
<p>All you need to do is install the WWW::Mechanize Perl module.</p>
<p>To install it under debian(ubuntu) do:</p>
<pre class="brush: css;"> # apt-get install libwww-mechanize-perl </pre>
<p>or<br />
from CPAN:</p>
<pre class="brush: css;"> #perl -MCPAN -e 'install WWW::Mechanize' </pre>
<p>Don&#8217;t forget to change the settings!</p>
<p>Feel free to modify it to your needs. Any suggestions for improvement are welcome.</p>
<pre class="brush: css;">

#!/usr/bin/perl -w
use WWW::Mechanize;
#this file is named wordpress_backup.perl

#Warning:
#1. If a file with a given name exists it'll be overwritten.
#2. Don't forget to escape special characters like @ in the password
#   variable.  Example:   q6@7mb   =&gt;  q6\@7mb

##############  Settings  #####################
my $username=&quot;YourUsername&quot;;
my $password =&quot;YourPassword&quot;;
my $path_to_file=&quot;/path/to/file/&quot;;
my $url=&quot;https://$username.wordpress.com/&quot;;
my $author=&quot;all&quot;;
#Filename format: fileprefix.date.xml
my $fileprefix=&quot;wordpress&quot;;
###############################################

#Change that if you want
my $agent=&quot;unixwayoflife/1.0&quot;;

my $date=((localtime)[5] +1900).&quot;-&quot;.((localtime)[4] +1).&quot;-&quot;.(localtime)[3];
my $mech = WWW::Mechanize-&gt;new( agent =&gt; $agent );
$mech-&gt;get( $url.&quot;wp-login.php&quot; );

##Log in
$mech-&gt;submit_form(
        form_name =&gt; 'loginform',
        fields    =&gt; { log  =&gt; $username, pwd =&gt; $password },
        button    =&gt; 'wp-submit'
   );
die &quot;ERROR: Incorrect password. Aborted.&quot; if $mech-&gt;content =~ m/Incorrect password/;
print (&quot;Login in \t\t\t[OK]\n&quot;);

#optional
sleep(2);

##Download the file
$mech-&gt;get($url.&quot;wp-admin/export.php?author=$author&amp;submit=Download+Export+File&amp;download=true&quot;);
$file_name=&quot;$fileprefix.$date.xml&quot;;
$mech-&gt;save_content( $path_to_file.$file_name );
print (&quot;Download \t\t\t[OK]\n&quot;);

#optional
sleep(2);

##Log Out
$mech-&gt;follow_link( text =&gt; 'Log Out' );
print (&quot;Login out \t\t\t[OK]\n&quot;);

print(&quot;File successfully saved in $path_to_file$file_name\n&quot;);
exit 0;
</pre>
<p>Run it:</p>
<pre class="brush: css;"> perl wordpress_backup.perl </pre>
<p>Sample output:</p>
<pre class="brush: css;"> username@debian:~$ perl wordpress_backup.perl
Login in                        [OK]
Download                     [OK]
Loging out                     [OK]
File successfully saved in /home/user/backups/wordpress.2008-11-12.xml  </pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/unixwayoflife.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/unixwayoflife.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/unixwayoflife.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/unixwayoflife.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/unixwayoflife.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/unixwayoflife.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/unixwayoflife.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/unixwayoflife.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/unixwayoflife.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/unixwayoflife.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unixwayoflife.wordpress.com&blog=5385081&post=3&subd=unixwayoflife&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://unixwayoflife.wordpress.com/2008/11/08/automated-wordpress-com-backup/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">unixwayoflife</media:title>
		</media:content>
	</item>
	</channel>
</rss>