How do I copy a Mac volume using cp?
I have researched this for hours. In Single User Mode, I used:
cp -Rpvn /* /Volumes/MyBackup
My external USB is mounted on /Volumes/MyBackup
The issue however is that after 24hrs it still has not stopped copying 300GB of data to an external USB drive. I think it is having issues with symbolic links such as the /Volumes/MacHD
volume also having a /Volumes/MacHD
and /Volumes/MyBackup
I am not sure about this however.
How do I copy a Mac volume using cp
? Is cp -Rpvn /* /Volumes/
MyBackup correct?
Solution 1:
Use rsync
for this purpose since cp
cannot faithfully reproduce all the files that exist on OS X. The benefits of rsync
over ditto
and cp
are:
- interrupted transfers can restart easily with very little cost.
- restarts even resume part way through a large file.
- file exclusion and --dry-run allow easy testing and iterative thinning.
The simplest way to use rsync
and preserve most things (permissions, symlinks, edit dates, etc) is to use the -a
or --archive
flag to archive. To see your progress use -P
or --progress
Rsync works as:
rsync options source destination
In your case I would recommend the following:
rsync --archive --verbose --one-file-system --human-readable --progress /from/ /to
Or in short:
rsync -avxhP /from/ /to
Mind the lack of trailing slash in the /to
location.
see comments for more useful flags
Solution 2:
If you want to make a faithful copy of the filesystem contents, avoid using cp
. Instead, use the ditto(1)
command, which preserves hard links, file permissions, resource forks, and HFS metadata. Unlike cp
, ditto
is meant to preserve as much of that information as possible by default.
It's just a matter of running sudo ditto src dest
.