Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
share|improve this question

1 Answer 1

The options that the BusyBox commands have depends a lot on the options that BusyBox 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. Normally cpio behaves more like an archive utility like tar, however it also has an extra function which allows it to copy files. To enable this in BusyBox, it needs to be built with FEATURE_CPIO_P defined (also LONG_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 with rsync 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):

find . -mtime -2 | cpio -o | { cd /media/USB_FLASH_2 && cpio -imd; }

Unfortunately the -o option can also be disabled in BusyBox (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:

    -o      Create (requires -H newc)

This changes the command to:

find . -mtime -2 | cpio -oH newc | { cd /media/USB_FLASH_2 && cpio -imd; }

This time I have tested with the cpio in the BusyBox 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.

share|improve this answer
    
Yes i was aware that -p was the main limiting factor and i'm glad you came up with a solution, i don't get any errors but it looks like it crashes? None of the files that should be copied arent there. I'm all up for using rsync but i'm not aware of how powerful it is, I thought it was like a cp/tar command in one. –  user62094 Mar 7 at 12:51
    
@user62094 Please edit your question an post any output you get. Please remember the ; (I forgot this at first and edited it in a few minutes later). Also, which shell are you using, the output of echo $0 should show which one. If you post another question for the rsync and add a link here, I will take a look. –  Graeme Mar 7 at 13:27
    
@user62094 updated, you need an extra option. –  Graeme Mar 7 at 16:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.