I have a new NAS box and after looking through numerous backup solutions I've found doing it manually through PuTTy to work the best.

After logging in to the box through PuTTy as root, I first need to copy the entire disk onto a USB HDD (well once every week). I have been using:

cp -Rp /data/Backup /media/USB_HDD_3/Backup

I have tried with rysnc -a instead and I get the similar results in that the files themselves keep the mtime but directories do not.

Then everyday I will be doing an incremental backup. For which I have been building:

find . -mtime -2 -exec cp -Rp {} /media/USB_FLASH_1/ \;

Again, I've tried substituting cp - Rp with rsync -a to no avail. I just end up getting the whole of the backup transferred, like it hasn't even looked at the mtime.

I'm rather new to Linux and Unix so most of this I have adapted from things I have found on the net and then tried to slot them together which is probably the reason it doesn't work.

  • rsync -a should preserve directory times too, it definitely works for me. What version of rsync do you have?
    – Graeme
    Mar 6, 2014 at 12:55
  • yes that was an error on my behalf, rsync -a does work.
    – user62094
    Mar 6, 2014 at 14:01

2 Answers 2


rsync -a should work if you simply do:

rsync -av /data/Backup /media/USB_HDD_3

If it isn't preserving directory timestamps, this is probably a bug in the rsync version. As an alternative, you could try GNU cpio:

find . -mtime -2 -print0 | cpio -0mdp /media/USB_FLASH_1

Or more portably (won't handle filenames with newlines):

find . -mtime -2 | cpio -mdp /media/USB_FLASH_1

Note that BusyBox builds often contain stripped down versions of the various tools. Even when built fully it is not completely POSIX compliant, also cpio isn't actually in the POSIX standard anymore. It is likely that your version of BusyBox is built without support for the -p option. You would need to use a cpio with these options enabled.

I tested the above with GNU cpio. I can't find a link to what the old standard for it was, but most likely anything compliant with it will support all these options except -0.

  • cpio: invalid option -- 'p' 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
    – user62094
    Mar 6, 2014 at 13:40
  • is the error i get when i run that 2nd piece of code, other than that the 1st error was my own carelessness, it seems that when you copy with windows it "creates" the folder again so my data was incorrect before i even started. I got around this and rsync -av /data/Backup /media/USB_HDD_3 worked like a charm.
    – user62094
    Mar 6, 2014 at 14:00
  • @user60294, the cpio issue is likely because your BusyBox has a stripped down version. See my updated answer for more info.
    – Graeme
    Mar 6, 2014 at 14:29
  • I see, i'm connecting to a ReadyNAS 102 through PuTTy SSH so i'm not sure how to install a newer/more complete version. If i can.
    – user62094
    Mar 6, 2014 at 15:28

rsync needs the update option to avoid transfering all files, man rsync give you the manual page and under options you will find,

    -u, --update                skip files that are newer on the receiver
        --inplace               update destination files in-place

To help understand what it is doing you can use -v option for verbose mode.

-v, --verbose This option increases the amount of information you are given during the transfer. By default, rsync works silently. A single -v will give you information about what files are being transferred and a brief summary at the end. Two -v options will give you information on what files are being skipped and slightly more information at the end. More than two -v options should only be used if you are debugging rsync.

  Note that the names of the transferred files that are output are done using
  a default --out-format of "%n%L", which tells you just the name of the file
  and, if the item is a link, where it points.  At the  single  -v  level  of
  verbosity,  this  does not mention when a file gets its attributes changed.
  If you ask for an itemized  list  of  changed  attributes  (either  --item‐
  ize-changes or adding "%i" to the --out-format setting), the output (on the
  client) increases to mention all items that are changed in  any  way.   See
  the --out-format option for more details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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