Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How would you emulate cp -al ?

0 views
Skip to first unread message

Henri Schomäcker

unread,
Feb 14, 2009, 10:20:28 AM2/14/09
to
Hi folks,

I need to emulate the copy command with preserves file & directory
attributes and hard-links files instead of copying.

This is normally done by "cp -al"

My problem is that I want to do that on a Terastation Pro II which uses a
busybox cp command which does not support the -l option.

So I am searching for a as simple as possible solution to emulate that which
should also be as fast as possible.

How would you do that?

Many thanks in advance,
yours Henri


John Stumbles

unread,
Feb 15, 2009, 6:21:50 PM2/15/09
to
On Sat, 14 Feb 2009 16:20:28 +0100, Henri Schomäcker wrote:

> I need to emulate the copy command with preserves file & directory
> attributes and hard-links files instead of copying.
>
> This is normally done by "cp -al"
>
> My problem is that I want to do that on a Terastation Pro II which uses a
> busybox cp command which does not support the -l option.

find, if it's not a file then cp -a it, else ln it?

--
John Stumbles

I used to think the brain was the most interesting part of the body
- until I realised what was telling me that

Henri Schomäcker

unread,
Feb 16, 2009, 2:00:29 PM2/16/09
to
John Stumbles wrote:

> On Sat, 14 Feb 2009 16:20:28 +0100, Henri Schomäcker wrote:
>
>> I need to emulate the copy command with preserves file & directory
>> attributes and hard-links files instead of copying.
>>
>> This is normally done by "cp -al"
>>
>> My problem is that I want to do that on a Terastation Pro II which uses a
>> busybox cp command which does not support the -l option.
>
> find, if it's not a file then cp -a it, else ln it?
>

First of all, don't need it anymore because I now use the rsync --link-dest=
option which I wanted to avoid because I preferred rsyncing at night and
rotating the backups at day.
Im' still testing but abandoning the transfer by ssh and optimising for
network speed gave me some more transmission in the backup-time-frame.

I also thought of the solution you mentioned but am sure that that's a very
resources-intensive solution because in the case of a full-backup the whole
server-installation would need to be searched.

I also found a solution using cpio but unfortunately cpio is also not
installed on a Terastation Pro II by default.

Replacing the OS unfortunately is also no option because it's not my box and
the customer does not want that because it might break the guarantee.

Many thanks for your answer John,

yours Henri

John Stumbles

unread,
Feb 16, 2009, 3:49:36 PM2/16/09
to
On Mon, 16 Feb 2009 20:00:29 +0100, Henri Schomäcker wrote:

> First of all, don't need it anymore because I now use the rsync
> --link-dest= option which I wanted to avoid because I preferred rsyncing
> at night and rotating the backups at day.


I was going to suggest rsync but thought if your cp didn't have -l what
would be the chances of having rsync?! :-)


--
John Stumbles

A backstreet vasectomy left me sterile

Henri Schomäcker

unread,
Feb 16, 2009, 6:02:07 PM2/16/09
to
John Stumbles wrote:

> On Mon, 16 Feb 2009 20:00:29 +0100, Henri Schomäcker wrote:
>
>> First of all, don't need it anymore because I now use the rsync
>> --link-dest= option which I wanted to avoid because I preferred rsyncing
>> at night and rotating the backups at day.
>
>
> I was going to suggest rsync but thought if your cp didn't have -l what
> would be the chances of having rsync?! :-)
>

Oh, this is very common for small network attached storage arrays.
The reason is they have rsync installed for the backup functions but don't
have coreutils installed but use busybox instead which emulates important
system commands.

The principle of busybox is that for example /bin/cp is a symlink to busybox
and when /bin/cp is called, busybox behaves like the cp command.
Pretty tricky, isn't it? :)

Yours,
Henri Schomäcker


John Stumbles

unread,
Feb 16, 2009, 6:51:26 PM2/16/09
to
On Tue, 17 Feb 2009 00:02:07 +0100, Henri Schomäcker wrote:

> The principle of busybox is that for example /bin/cp is a symlink to
> busybox and when /bin/cp is called, busybox behaves like the cp command.
> Pretty tricky, isn't it? :)

Standard *n*x trickery, methinks :-)

What's a busybox anyway - some sort of NAS device? (Sorry, I know I should
STFW :-))

--
John Stumbles

Life is nature's way of keeping meat fresh

Maxwell Lol

unread,
Feb 16, 2009, 9:56:42 PM2/16/09
to
John Stumbles <john.s...@ntlworld.com> writes:

> What's a busybox anyway - some sort of NAS device? (Sorry, I know I should
> STFW :-))

http://www.busybox.net/downloads/README

What is busybox:

BusyBox combines tiny versions of many common UNIX utilities into a single
small executable. It provides minimalist replacements for most of the
utilities you usually find in bzip2, coreutils, file, findutils, gawk, grep,
inetutils, modutils, net-tools, procps, sed, shadow, sysklogd, sysvinit, tar,
util-linux, and vim. The utilities in BusyBox often have fewer options than
their full-featured cousins; however, the options that are included provide
the expected functionality and behave very much like their larger
counterparts.

Henri Schomäcker

unread,
Feb 17, 2009, 11:12:46 AM2/17/09
to
Maxwell Lol wrote:

Many thanks Maxwell for your very good explanations!

just want to add (may only be important for those who are interested in the
thread subject) that the actual version of busybox also supports the -l
option for the cp command.

Yours Henri

0 new messages