I'm trying to do an incremental backup using cpio but it seems that the busybox version doesn't work the same as the normal one? This is what I've got so far:
find data/Backup -mtime -2 | cpio -cm media/USB_FLASH_2
I origianlly used:
find . -mtime -2 | cpio -cm /media/USB_FLASH_2
However, I've seen people say busybox doesn't like definitive paths while using cpio. Unsure about that though.
It returns an error that basically says I'm using cpio wrong. I can't find anyone using the busybox cpio to do things like this, does that mean i can't do it? I've looked at using rsync as well but again, it doesn't do what i would expect.
For reference I'm using PuTTY to connect through SSH to a ReadyNAS 102.
After using find . -mtime -2 | cpio -o | { cd /media/USB_FLASH_2 && cpio -imd; }
i get the output:
BusyBox v1.20.2 (Debian 1:1.20.0-7) multi-call binary.
Usage: cpio [-dmvu] [-F FILE] [-H newc] [-tio] [EXTR_FILE]...
Extract or list files from a cpio archive, or
create an archive using file list on stdin
Main operation mode:
-t List
-i Extract EXTR_FILEs (or all)
-o Create (requires -H newc)
-d Make leading directories
-m Preserve mtime
-v Verbose
-u Overwrite
-F FILE Input (-t,-i,-p) or output (-o) file
-H newc Archive format
Best Answer
The options that the
BusyBox
commands have depends a lot on the options thatBusyBox
is compiled with.BusyBox
aims to be highly configurable so that very small cut down versions can be compiled for systems where resources are very limited. Larger, more full featured versions can be built where this isn't an issue.In your case
cpio
needs the-p
or--pass-through
(long form) option enabled. Normallycpio
behaves more like an archive utility liketar
, however it also has an extra function which allows it to copy files. To enable this inBusyBox
, it needs to be built withFEATURE_CPIO_P
defined (alsoLONG_OPTS
for long form options to be enabled for any program).From your last question, I strongly recommend that you use
rsync
for what you are doing. You are probably better off asking another question detailing exactly what you are doing withrsync
and why it doesn't do what you expect.rsync
is an extremely versatile tool and can no doubt be configured to do what you want.That said, you could try the following with
cpio
, this will create an archive and then extract it again (somewhat less efficient, but still the same result):Unfortunately the
-o
option can also be disabled inBusyBox
(FEATURE_CPIO_O
build option), so this may not work either.Update
Based on this line of output, you need to add an extra option when creating an archive:
This changes the command to:
This time I have tested with the
cpio
in theBusyBox
for my own system and it works for me, however in some cases the mtimes for directories won't be preserved.rsync
should be the best way to do this.