<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(11,83,148)">Matt, </div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(11,83,148)">
<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(11,83,148)">While I don't have hard links (mainly soft links) in my working directories, I am using hard links in my incremental backup strategy. I implement the following simple script to create a rotating backup using rsync's --link-dest=[filename]. I would be curious to see what others thought of this approach to incremental backups:</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(11,83,148)"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(11,83,148)">
Here is the script:</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(11,83,148)"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(11,83,148)">
<div class="gmail_default">#!/bin/bash</div><div class="gmail_default"># Backup script written by JHDugger 4/26/12. </div><div class="gmail_default"># Modified from <a href="http://webguru.com/linux/rsync_incremental.php">http://webguru.com/linux/rsync_incremental.php</a></div>
<div class="gmail_default"><br></div><div class="gmail_default"># Todays date in ISO-8601 format:</div><div class="gmail_default">DAY1=`date -I`</div><div class="gmail_default"><br></div><div class="gmail_default"># Yesterdays date in ISO-8601 format:</div>
<div class="gmail_default">DAY0=`date -I -d "1 day ago"`</div><div class="gmail_default"><br></div><div class="gmail_default"># The source directory:</div><div class="gmail_default">SRC="/srv/tacs-host1/backup/"</div>
<div class="gmail_default"><br></div><div class="gmail_default"># The target directory:</div><div class="gmail_default">TRG="/srv/tacs-host1/archive/$DAY1"</div><div class="gmail_default"><br></div><div class="gmail_default">
# The link destination directory:</div><div class="gmail_default">LNK="/srv/tacs-host1/archive/$DAY0"</div><div class="gmail_default"><br></div><div class="gmail_default"># The rsync options:</div><div class="gmail_default">
OPT="-avh --delete --link-dest=$LNK"</div><div class="gmail_default"><br></div><div class="gmail_default"># Execute the backup</div><div class="gmail_default">rsync $OPT $SRC $TRG</div><div class="gmail_default">
<br></div><div class="gmail_default">#121 days ago in ISO-8601 format</div><div class="gmail_default">DAY121=`date -I -d "121 days ago"`</div><div class="gmail_default"><br></div><div class="gmail_default">#Delete the backup from 120 days ago, if it exists</div>
<div class="gmail_default">if [ -d /srv/tacs-host1/backup/$DAY121 ]</div><div class="gmail_default">then</div><div class="gmail_default">rm /srv/backup/$DAY121</div><div class="gmail_default">fi</div><div class="gmail_default">
<br></div><div class="gmail_default" style>This script creates a subdirectory with today's date under a directory called 'archive' and then proceeds to read changed files from the previous day's archive directory, copy and link any changed files from this directory to today's archive. It then proceeds to delete the directory that is 121 days old.</div>
</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jul 10, 2013 at 9:43 AM, Matt Graham <span dir="ltr"><<a href="mailto:danceswithcrows@usa.net" target="_blank">danceswithcrows@usa.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">> Rusty.Carruth wrote:<br>
>> First, if you are not using 'tar' or 'cpio' or other program which<br>
>> correctly handles 'character (and block) special files' you will sooner<br>
>> or later find yourself copying much more than you should (think pipes<br>
>> and other character or block special files<br>
<br>
</div>rsync. While rsync will not handle hard links in the optimal way by default,<br>
how many people actually have hard links on their filesystems these days?<br>
Also, char and block devices would only be found in /dev in just about any<br>
case I can think of, and backing up /dev seems a bit like a waste of time<br>
since udev manages it.<br>
<br>
From: Michael Havens<br>
<div class="im">> Yep,.... the advice to chown the file got lost in the shuffle<br>
<br>
</div>Yes, this is why it's important to read the whole message and understand it<br>
when you're talking about semi-complicated technical things.<br>
<div class="im"><br>
> however after I did that I click it and 'run in terminal'. then a shell<br>
> opens and it says "building file list" and then something flashes<br>
> across the screen and the terminal closes itself.<br>
<br>
</div>This probably means there's some sort of error happening. So, open a konsole<br>
or gnome-terminal and run the backup script inside that terminal, which will<br>
allow you to see what the error is. This is pretty basic, and I thought you<br>
had done it already.<br>
<div class="im"><br>
>> If you need to restore from the backup disk, just mount it. The<br>
>> command for doing that is in the script ("mount /mnt/backup").<br>
</div><div class="im">> as for restoring the backup isn't there a way to retrieve one file?<br>
<br>
</div>If you mount a disk on /mnt/backup , then rsync your ~ to /mnt/backup/bmike/ ,<br>
that means that /mnt/backup/bmike/ will contain an exact copy of your ~. This<br>
means that finding 1 file under /mnt/backup/bmike/ and copying it to<br>
/home/bmike/ should be a very simple and easy thing.<br>
<div class="HOEnZb"><div class="h5"><br>
--<br>
Matt G / Dances With Crows<br>
The Crow202 Blog: <a href="http://crow202.org/wordpress/" target="_blank">http://crow202.org/wordpress/</a><br>
There is no Darkness in Eternity/But only Light too dim for us to see<br>
<br>
---------------------------------------------------<br>
PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org">PLUG-discuss@lists.phxlinux.org</a><br>
To subscribe, unsubscribe, or to change your mail settings:<br>
<a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><font color="#0b5394">James</font><div><br><span style="color:rgb(255,255,255)"><span style="background-color:rgb(11,83,148)"><b><a href="http://www.linkedin.com/pub/james-h-dugger/15/64b/74a/" target="_blank"><span style="background-color:rgb(255,255,255)"><span></span><span style="color:rgb(11,83,148)">Linkedin<span></span></span></span></a></b></span></span><br>
</div></div>
</div>