: all you Terminal guru's out there
highcadence Apr 15th, 2012, 12:31 PM I wanted to know the best way to copy all the contents of one (1 Tb) USB external drive /dev/disk1s2 to a new (2Tb) (/dev/disk2s2) via terminal.
what's the best set of commands to "cp -rv" everything from /dev/disk1s2/ to /dev/disk2s2 ?
thx for any suggestions
macintosh doctor Apr 15th, 2012, 12:50 PM just a question here.. why do not you use drive genious or carbon copy to do a sector copy?
as for commands
How to copy a directory or folder. (http://www.computerhope.com/issues/ch000838.htm)
highcadence Apr 15th, 2012, 12:51 PM i just think its more fun using the terminal :-)
thx
macintosh doctor Apr 15th, 2012, 01:00 PM i just think its more fun using the terminal :-)
thx
well then.. hope you back up before you have your fun :D
broad Apr 15th, 2012, 04:34 PM In the time it took to make this post you could have started the clone using CCC or disk utility haha
WCraig Apr 15th, 2012, 10:19 PM I think rsync is the fastest way to duplicate src to dest:
copy with progress bar - rsync | commandlinefu.com (http://www.commandlinefu.com/commands/view/8967/copy-with-progress-bar-rsync#comment)
but at least one alternative is suggested...
Craig
WCraig Apr 15th, 2012, 10:23 PM Oh, and if you want a more up-to-date version of rsync, MacPorts is a pretty painless way to get it (and many, many other useful tools).
The MacPorts Project -- Home (http://www.macports.org/)
Craig
mguertin Apr 16th, 2012, 12:19 PM Beware using rsync ... unless you have a lot of rsync experience you can end up with a lot of headache for nothing (hard links, soft links, resource forks, etc). Also if you're not using the proper version(s) of rsync and you're not passing the appropriate command line options you can end up destroying your data. The MacPorts version is ok but Mike Bombich's patches (author of CCC) are probably the best ones out there for rsync and OSX. You can find them here: Bombich.com: Mac OS X and HFS+ enhancements for rsync 3 (http://www.bombich.com/rsync.html)
That said I'll second (third?) the suggestion for using disk image or carbon copy cloner (which is free). BTW, CCC uses rsync in the backend for many of its copying tasks.
biovizier Apr 17th, 2012, 08:43 PM For file level copies, I'm partial to 'ditto' myself. It isn't as fast as 'rsync' but at least in the past, was more Mac metadata-friendly.
Also note that for drives containing hard-linked directories (eg. those used with TimeMachine), it will probably be necessary to go with something like 'dd' to do block-level copies.
pm-r Apr 18th, 2012, 02:23 AM Beware using rsync ... unless you have a lot of rsync experience you can end up with a lot of headache for nothing (hard links, soft links, resource forks, etc). Also if you're not using the proper version(s) of rsync and you're not passing the appropriate command line options you can end up destroying your data. The MacPorts version is ok but Mike Bombich's patches (author of CCC) are probably the best ones out there for rsync and OSX. You can find them here: Bombich.com: Mac OS X and HFS+ enhancements for rsync 3 (http://www.bombich.com/rsync.html)
That said I'll second (third?) the suggestion for using or carbon copy cloner (which is free). BTW, CCC uses rsync in the backend for many of its copying tasks.
I'll go with the CCC (and occasionally the Disk Utility disk image) option, but I like and prefer to use Mike's CCC developer's comment:
"If you would rather avoid the following procedure, you can benefit from these enhancements to rsync by downloading Carbon Copy Cloner, which uses rsync for many of its file copying operations."
MUCH more user friendly, customizable if needed and MUCH safer IMHO.
mguertin Apr 18th, 2012, 12:53 PM For file level copies, I'm partial to 'ditto' myself. It isn't as fast as 'rsync' but at least in the past, was more Mac metadata-friendly.
Also note that for drives containing hard-linked directories (eg. those used with TimeMachine), it will probably be necessary to go with something like 'dd' to do block-level copies.
SuperDuper handles hard links properly. CCC doesn't by default, but I think it can be forced into handling things nicely with the advanced options (I rarely use them as I'm a bit of an rsync junkie anyway -- there are rsync options for hard link handling that I think you can pass with CCC advanced settings).
rsync is much, much better with metadata and the like these days, provided you're using an appropriate version (i.e. Mike Bombich's rsync patches). ditto had it's time in the sun and in fact CCC used to use ditto but has since switched to rsync for it's backend bits. Also ditto doesn't support some of the nicer things that rsync does, such as copying only changed items, the ability to archive older versions of things, compressions during transfer, ssh connections for remote transfers, encrypted transport, etc. I think Apple honestly keeps ditto around because every release they seem to toss more and more things into it .. the type of things that are like "Where do we put this ... I know! ditto!"
dd and/or Disk Utility are pretty safe as well. I think (but am not positive) that the backend of Disk Utility uses dd (or a variant of it) when doing full disk image stuff. One issue with using dd is to make sure you get your block sizes correct for the devices in question or you could end up with a big mess of unusable data :(
Long story short for the OP ... stick to CCC or SuperDuper or Disk Utility and be happy unless you want to go pretty deep into the rabbit hole ;)
biovizier Apr 19th, 2012, 12:51 AM The various utilities all have their uses and pros and cons. In fact, I use 'rsync' almost every day for incremental backup of my pocket USB drive. But since OP specifically said they wanted to copy "all the contents of" one drive to another presumably as a one shot deal, I though 'ditto' could get the job done more easily.
For one thing, 'ditto' so far has been very well maintained to keep it current with respect OS X compatibility -- eg. according to the 'man' page, "preserve resource forks and HFS meta-data" (default since 10.4), "Preserve extended attributes", "preserve quearantine information", "preserve ACLS" (all default since 10.5) and "preserve HFS compression" (default since 10.6) shows that 'ditto' is being updated to accomodate new features used by OS X.
Furthermore, the new OS X features are rolled into the default option -- in other words, there is no need to remember a bunch of flags. Note that the above applies to the stock 'ditto' that can be found on any Mac (running the appropriate OS X version) so you don't have to go looking for third party versions to get the version that is compatible. With fewer flags to remember there is less risk to the source, especially since its purpose is to ditto (copy) rather than sync source and destination.
As far as hard links are concerned, note that the key point is hard-linked directories. Hard links to files is old hat. Hard links to directories is something that isn't generally supported in *nix but something that Apple uncharacteristically uses for TimeMachine. I'm not aware of any file-level utilities installed by default in "OS X" that are aware of hard-linked directories, hence the necessity to go to something block based like 'dd'.
CarbonCopyCloner or SuperDuper are great utilities that have served the Mac community well. But I hasten to remind everyone that this forum section is titled "Anything Mac" and the command line tools have been a part of the default "OS X" installation for a long time. If someone expresses an interest in exploring them as the OP has, I think that interest should be encouraged.
biovizier Apr 19th, 2012, 01:02 AM Hmmm, after further exploration, I concede that 'rsync', by failing to recognize what they are, handles hard-linked directories much more elegantly than 'ditto'. I would go so far as to say that the behaviour of 'ditto' can serve as a text book demonstration of why it might be a good idea to avoid hard linking directories...
But barring the presence of hard links (which is atypical), I still think 'ditto' is easier to use for file-level copies. And definitely stick to 'dd' if hard-linked directories are involved.
mguertin Apr 19th, 2012, 04:22 PM Yes ditto is being updated, but it's also becoming the repository for all kinds of things that I don't think should be part of it... like stripping fat binaries, creating and extracting archives, etc. I can kind of understand why they added this type of stuff, but it doesn't mean that I agree with the design direction for it. For the geeks in the crowd ditto does have some big downfalls depending on what you need to do ... namely (from the man page: "Pipes, sockets, and files with names beginning with .nfs or .afpDeleted will be ignored" ... personally I can't say that I'm a fan of a copying utility that arbitrarily ignores things!
I use rsync many times daily -- I have a lot of scripts that take care of backups for me that use it exclusively. One of the things that I really love about it is it's flexibility ... like the ability to go from local copy to encrypted remote copies (via ssh transport) with various degrees of compression, bandwidth throttling, really great system for includes/excludes, the way it handles a path like somedir and somedir/ differently, and the list goes on. rsync has been around for a long time and has had a serious amount of thought put into the design. ditto ... not so much. I may be wrong but I thought that ditto kind of gained life from a bunch of perl addons(?)
I have been rolling my own backup scripts with rsync since the 90's and they still run perfectly to this day across several OSes :)
| |