<?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>Norse Technologies Knowledge Base&#187; myfile</title>
	<atom:link href="http://kb.norsetech.net/tag/myfile/feed/" rel="self" type="application/rss+xml" />
	<link>http://kb.norsetech.net</link>
	<description>Free Knowledge Articles</description>
	<lastBuildDate>Wed, 11 Jan 2012 00:53:34 +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 Make a Backup Script for Shell in Linux</title>
		<link>http://kb.norsetech.net/how-to-make-a-backup-script-for-shell-in-linux/</link>
		<comments>http://kb.norsetech.net/how-to-make-a-backup-script-for-shell-in-linux/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 02:47:18 +0000</pubDate>
		<dc:creator>kb-admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[backing up files]]></category>
		<category><![CDATA[backup copy]]></category>
		<category><![CDATA[backup script]]></category>
		<category><![CDATA[code comments]]></category>
		<category><![CDATA[command]]></category>
		<category><![CDATA[command line argument]]></category>
		<category><![CDATA[command line interface]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[config files]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[DATECODE]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[good habit]]></category>
		<category><![CDATA[habit]]></category>
		<category><![CDATA[IMHO]]></category>
		<category><![CDATA[line]]></category>
		<category><![CDATA[myfile]]></category>
		<category><![CDATA[time]]></category>
		<category><![CDATA[TIMECODE]]></category>

		<guid isPermaLink="false">http://kb.norsetech.net/?p=182</guid>
		<description><![CDATA[For those who hack a lot of Linux at the command line interface, backing up files such as config files before editing is a good habit to have. IMHO anyway. So to save time, a little script can be written, chmod +x, and placed into /usr/local/bin or some other that users have in their executable [...]]]></description>
			<content:encoded><![CDATA[<p>For those who hack a lot of Linux at the command line interface, backing up files such as config files before editing is a good habit to have. IMHO anyway. So to save time, a little script can be written, chmod +x, and placed into /usr/local/bin or some other that users have in their executable shell PATH. I name mine &#8220;bu&#8221; to make it easy, and it takes one command line argument which is the filename of the file you want to make a backup copy of. It is called by running something like <strong>$ bu <em>myfile </em></strong></p>
<p><strong><em></em></strong>Here&#8217;s the code. Comments welcome ;) The code creates a timecode based on today&#8217;s date and the current time to the second, and appends that to the original filename. The a copy is saved with this new &#8220;timestamped&#8221; backup filename, right in the same directory. Easy-peasy! <strong><em></em></strong></p>
<pre>#!/bin/bash
OLDFILENAME=$1
DATECODE=$(date +%Y%m%d)
TIMECODE=$(date +%H%M%S)
NEWFILENAME="${OLDFILENAME}_backup${DATECODE}-$TIMECODE"
cp $OLDFILENAME $NEWFILENAME
SUCCESS=$?
if [ $SUCCESS -eq 0 ];then
 echo "OK! Copied \"$OLDFILENAME\" to \"$NEWFILENAME\""
else
 echo "FAIL! You'll need to try again!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
fi</pre>
]]></content:encoded>
			<wfw:commentRss>http://kb.norsetech.net/how-to-make-a-backup-script-for-shell-in-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

