Dirsync

From wikipost
Revision as of 00:22, 29 September 2011 by Admin (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Dirsync is a script I wrote to synchronise directories when a system boots up or shuts down.

Background

To provide some basic network functionality (DNS, logging stats, a webserver, etc..) I used to run Debian on a Linksys NSLU2 for many years. The NSLU2 is a small device, fanless with an internal Disk-on-chip (flash) for storing the original Operating System (with Debian it's running off a 1GB USB flash drive). Around June 2010 I upgraded to a more powerful alternative, the Sheeva Plug. Small, fanless, internal flash and an SDCard slot (from which I'm running the O/S). I leave these machines running 24/7 and I want them to be quiet and consume as little power as possible. I therefore use an SDCard to place the O/S on. Since SDCards fail much faster than spinning HDD's during normal operation I make sure the system is optimised to write as little to the disk as possible. Most logging is turned off, I make extensive use of RAM filesystems (ramfs) and for additional (non-O/S) data storage I use a 2.5" USB HDD (which spins down and powers off after so many minutes of inactivity).

For logging some system statistics I use rrdtool and to prevent rrdtool from constantly writing to the SDCard flash I put the datbase file (.rrd) in a RAM filesystem.

My main reason for writing this script is because I didn't want to lose my .rrd files every time the system shuts down.

This script will sync from one directory to another (saving the .rrd from /dev/shm/rrd to /var/lib/rrd) when the system shuts down and copies it back (restoring the database back to /dev/shm/rrd) upon system boot up.

The script also has an 'update' feature which updates to the backup directory (to /var/lib/rrd in this example) to make sure we don't lose too much information in case the server shuts down without going through the normal shutdown procedure (e.g. in case of a power outage). I run the 'update' feature only once a week, which is the trade off between losing database information and losing the SDCard due to extensive write cycles.



Latest version: File:Dirsync-1.0.tar.gz


http://www.globalscaletechnologies.com/p-22-sheevaplug-dev-kit-us.aspx

http://en.wikipedia.org/wiki/SheevaPlug

http://en.wikipedia.org/wiki/NSLU2

http://www.nslu2-linux.org/