LWN.net Logo

CLI Magic: Simple backup is Mirdir (Linux.com)

Linux.com shows how to create mirror directories with Mirdir. "Mirdir is licensed under the GPL. You can download your choice of an executable RPM, source RPM, or a source tarball. To install it on my SUSE 10 desktop box, I chose the executable RPM, used su to install as root, and entered rpm -Uvh mirdir-2.1-1.i386.rpm. On my Ubuntu Breezy machine, I decompressed the tarball, entered the Mirdir subdirectory, ran ./configure and make."
(Log in to post comments)

rsync?

Posted Nov 21, 2005 20:58 UTC (Mon) by cantsin (guest, #4420) [Link]

I wonder what mirdir offers over rsync.

rsync?

Posted Nov 21, 2005 21:58 UTC (Mon) by fjf33 (subscriber, #5768) [Link]

Or unison for that matter.

rsync?

Posted Nov 21, 2005 22:10 UTC (Mon) by tjw.org (guest, #20716) [Link]

Heh, it's not even close to rsync.

It's slightly more advanced than 'cp -a' because it supports exclude lists and does some checking to make sure every file isnt' copied every time. However, it doesn't look like it does anything advanced when examining the directories like rsync does. From the mirdir manual:

       -t count
              Counter of bytes to be compared in files which look equal.

       -s     Compare the  full  content  of  files,  ignoring  -t  option  if
              present.

Also it doesn't appear to support ssh tunneling (or any network capability).

I seriously question the experience level of the person who writes the CLI Magic series. Assuming the target audience is novices, why not show them how to use a much more useful tool that is probably already installed on their machine instead of sending them off on a wild goose chase?

rsync?

Posted Nov 22, 2005 1:22 UTC (Tue) by warthawg (guest, #3055) [Link]

"I seriously question the experience level of the person who writes the CLI Magic series. Assuming the target audience is novices, why not show them how to use a much more useful tool that is probably already installed on their machine instead of sending them off on a wild goose chase?"

He's no sys admin, that's for sure. :)

I'm just a lame Linux user who has been using it since about 95, and as his exclusive desktop since 98. The column is definitely for noobies, and rsync has already been covered in a column I wrote in April. And I guess I should come clean about the fact that my rank (Corporal-for-life in the Linux Liberation Army) is an honorary one, that I awarded myself.

That said, I really think some people need to get over the notion that writing about a tool means the author loves it, or swears in blood it's the best of breed, or implies anything at all which is even remotely close to that.

That sort of thinking implies a mindset as infantile as "my distro can beat up your distro." Or substitute desktop enviroment, email client, ripper, desktop OS, server OS, whatever else you want to argue about for distro in that template.

Mirdir is a fine tool for some purposes, and for some people. Like rsync better anyway? Fine. I think it is a little bit of overkill for local copies, copying data to a keydisk, and similar tasks that a normal user is likely to need to do, but whatever. Mirdir's deal is simplicity, rsync's power comes from being able to do much more than that. IMO, newbies like and appreciate simple.

Joe Barr

rsync?

Posted Nov 22, 2005 6:22 UTC (Tue) by sitaram (subscriber, #5959) [Link]

First, I've always enjoyed Joe Barr's columns, and I particularly liked his you-can-almost-hear-him-sighing-in-despair repost in the comments section of the article over on linux.com.

Having said that, this is for Joe. And I'm speaking for myself :-)

I've used Linux since about 95 (my first distro was Yggdrasil!), and I'll let the rest of it go unsaid (not that there's too much). I've now come to the point that, for every task I have, I look for one tool that is as much of a superset of everything else as possible, simply because -- lemme say it outright -- I'm too old to remember all of them :-( I don't always find the "one ring", but I look for it anyway!

Which is why I agree with the idea that when talking about a new tool, a reference can be made to similar tools with a short bit of info, just to give us "crusty old geeks" a very brief comparision. Please dont read it as a "my ditro can beat up your distro" situation. I'm too old for that kind of stuff too :-)

In this example, something like "For power users, rsync [URL of your previous article here] offers more choices, at the price of more complexity. For example, leave off the final slash on the source dir and see how long you take to figure out what went wrong!" would have been appropriate.

I'd hate to offend Joe -- I've learnt a lot from him. But I still wish I hadn't spent time downloading and looking at mirdir, and something like the example para above would have helped me avoid that.

rsync?

Posted Nov 22, 2005 8:38 UTC (Tue) by hppnq (guest, #14462) [Link]

I could, of course, recommend mirrordir as a much better alternative, but I would be joining the wrong choir. The only real solution is painfully obvious: install a proper logical volume manager, rsync and friends are for wimps.

Seriously, I like articles like these: simple solutions for simple but real problems. Users always have the option to adjust their tools to their needs and experience, sysadmins should know how to pick the right tool for the job in the first place.

So by all means, Joe, keep it coming.

rsync?

Posted Nov 22, 2005 12:25 UTC (Tue) by khim (subscriber, #9252) [Link]

I could, of course, recommend mirrordir as a much better alternative, but I would be joining the wrong choir. The only real solution is painfully obvious: install a proper logical volume manager, rsync and friends are for wimps.

I keep backup of my files on system thousand miles away from my main one. With rsync. Now: how exactly can I do this with "proper logical volume manager" ? On the other hand I hardly find a task not doable with rsync but doable with mirrordir...

rsync?

Posted Nov 22, 2005 20:23 UTC (Tue) by hppnq (guest, #14462) [Link]

Heh, it was meant to be ironic, sorry if it didn't appear that way. (You might try combining lvm and nbd though. ;-)

The point I was trying to make is not whether rsync is able to solve a problem (such as making a simple local backup), but whether it is the most appropriate tool for the job.

rsync?

Posted Nov 23, 2005 17:31 UTC (Wed) by grouch (guest, #27289) [Link]

Some crusty warthawg said, from the back porch:
"Mirdir's deal is simplicity, rsync's power comes from being able to do much more than that. IMO, newbies like and appreciate simple."

From the article:
mirdir -enone /home/username/text-files /home/username/text-mirror

From experience:
rsync -avz /home/username/text-files/ /home/username/text-mirror

No more complicated for newbies to learn than mirdir; actually, it takes fewer keystrokes. Not any more cryptic, either.

Now, if I wanted to delete old versions:
rsync -avz --delete /home/username/text-files /home/username/text-mirror

How about if a friendly 'root' mounted some Compact Flash disk on a usb card reader for me?
rsync -avz --delete ./my_text_files/ /mnt/temp/my_text_files

How about mirroring to some website where I have an ssh account?
rsync -avz --delete -e ssh ./my_text_files/ me@there:my_home/my_text_files

The article does a good job of introducing 'mirdir', which I had never heard of until now. As someone else pointed out, it would be helpful to mention other similar tools.

Thanks for your continuing work, Joe!

CLI Magic: Simple backup is Mirdir (Linux.com)

Posted Nov 22, 2005 9:30 UTC (Tue) by janpla (guest, #11093) [Link]

What I wonder is - how is it different from, say, (cd /from-dir;tar cf * -)|(cd /to-dir; tar xf -)?

CLI Magic: Simple backup is Mirdir (Linux.com)

Posted Nov 22, 2005 10:25 UTC (Tue) by hppnq (guest, #14462) [Link]

Your example is a quick hack that has nothing to do with synchronization/mirroring and is definitely not extremely suitable for newbies (or anyone else, for that matter). For crying out loud, at least read the article that you are commenting on.

Comparison with TSM anyone?

CLI Magic: Simple backup is Mirdir (Linux.com)

Posted Nov 22, 2005 21:25 UTC (Tue) by tjw.org (guest, #20716) [Link]

Your example is a quick hack that has nothing to do with synchronization/mirroring and is definitely not extremely suitable for newbies (or anyone else, for that matter).

That is completely untrue. This command has everything to do with mirroring. This method has been around a very long time and is commonly used and documented. Often it's attributed to Alan Cox in Linux related HOWTO's.

In fact, before "-a" became an option for GNU cp, this was THE way to archive a directory. Perhaps it still is on non-GNU systems that lack the cp archive option (e.g. Mac OSX).

I still use a varaition of this command from time to time.

For example if I want to mirror a directory containing millions of files totalling over a TiB in disk space; I wouldn't want use the following command for the intitial copying:

rsync -azP somehost:/some/dir/ /some/dir/

This is because this command could take days to complete and could make the machine swap to death as it deals with the mind bogglingly huge checksumming. Instead, I would use a very simpistic command that uses the smallest amount of CPU and RAM possible:

ssh somehost "cd /some/dir && tar czf -" | tar zxvf -

CLI Magic: Simple backup is Mirdir (Linux.com)

Posted Nov 22, 2005 23:26 UTC (Tue) by hppnq (guest, #14462) [Link]

That is completely untrue. This command has everything to do with mirroring.

Nope, it has to do with archiving or moving data around, like you seem to observe yourself a few lines further on. Look up a definition of mirroring or hey, read the article! And yes, cp -a or -rp is the way to go of course. Consult the tar manpage for a hint of why this is a quick hack not suitable for mirroring, the synopsis should do it.

ssh somehost "cd /some/dir && tar czf -" | tar zxvf -

That makes more sense, yes. How exactly does it relate to mirdir?

CLI Magic: Simple backup is Mirdir (Linux.com)

Posted Nov 23, 2005 16:47 UTC (Wed) by tjw.org (guest, #20716) [Link]

Consult the tar manpage for a hint of why this is a quick hack not suitable for mirroring, the synopsis should do it.
Sorry, you'll have to be more specific. I don't see any reason why this is bad practice in the tar man or info pages.
Nope, it has to do with archiving or moving data around, like you seem to observe yourself a few lines further on. Look up a definition of mirroring or hey, read the article!

I did read the article.

I define mirroring a directory as "making an exact copy of the directory". A mirror copy, if you will. To me, this means that all files, permissions, ownership, timestamps, and special files like devices should be exactly the same in both copies.

That makes more sense, yes. How exactly does it relate to mirdir?

It relates to mirdir only because it's a different method of achieving the same end. While mirdir/mirrordir/rsync do some checking to eliminate unnecessary copying, cp or tar can be used to copy everything every time. My point was that there are cases when the latter method is preferrable.

CLI Magic: Simple backup is Mirdir (Linux.com)

Posted Nov 23, 2005 21:29 UTC (Wed) by hppnq (guest, #14462) [Link]

Sorry, you'll have to be more specific.

Metadata. Portability. See your definition of mirroring:

To me, this means that all files, permissions, ownership, timestamps, and special files like devices should be exactly the same in both copies.

You forget one quite important aspect: synchronization. This is what sets a mirror apart from an archive or a snapshot, for instance. Of course the concepts overlap: you can make an archive out of a mirror and the other way around.

It relates to mirdir only because it's a different method of achieving the same end.

Your tar | ssh | tar example served to illustrate a powerful variation of the original tar | tar example. But it has nothing to do with mirdir, which is entirely different, and explained in the article in a way that even a newbie can understand it.

Anyway, we're boring everybody's pants off, mine are in the laundry already. The point I wanted to make is: Joe wrote an article intended for newbies about making a simple local backup using a simple command -- and you take offence, because rsync appears to be a superior solution:

I seriously question the experience level of the person who writes the CLI Magic series.

I seriously question your reading abilities and your judgment. Like I said: I think articles like these are quite nice, because they help unleash some of the power that Linux offers to unexperienced users. And obviously you don't know Joe Barr.

CLI Magic: Simple backup is Mirdir (Linux.com)

Posted Nov 24, 2005 10:28 UTC (Thu) by mp (subscriber, #5615) [Link]

For example if I want to mirror a directory containing millions of files totalling over a TiB in disk space; I wouldn't want use the following command for the intitial copying:

rsync -azP somehost:/some/dir/ /some/dir/

This is because this command could take days to complete and could make the machine swap to death as it deals with the mind bogglingly huge checksumming.

True, though the --whole-file option of rsync would help with the checksumming problem.

CLI Magic: Simple backup is Mirdir (Linux.com)

Posted Nov 27, 2005 3:03 UTC (Sun) by zblaxell (subscriber, #26385) [Link]

The problem isn't checksumming. By default rsync does no checksumming until it encounters a file that exists on both source and destination with different size or timestamp, unless you add '-c'.

The problem is that rsync *requires* a full list of all files be generated and sent to the client, with both client and server having a copy of this list stored in RAM, before *any* data is transferred. A 32-bit processor has enough address bits for a few million files. After that, you need better software, or more address bits.

Copyright © 2005, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds