Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like to find a more solid and handy solution to my small problem.. My idea is to backup every midnight my home directory incrementally, so I want only the modified files (of today) to be copied to my external drive. I have prepared a script which does this:

find /home/user/* -mtime -1 -exec cp -r {} /media/Elements/BACKUP/ \;

It works but I noticed that it does not keep the full path name, and after the first day under /media/Elements/BACKUP I find all the latest files, as example:

If I modify /home/user/a/b/c.dat I'll find c.dat under /media/Elements/BACKUP/c.dat but I would like to have it of course under /media/Elements/BACKUP/a/b/c.dat Is there an simple flag to add to "find".. or some other trick?

share|improve this question

migrated from stackoverflow.com Dec 16 '12 at 17:41

This question came from our site for professional and enthusiast programmers.

1 Answer 1

up vote 0 down vote accepted

Maybe it would be easier to use a program like rsync instead of cp. rsync is designed to do that kind of stuff.

http://en.wikipedia.org/wiki/Rsync

http://linux.die.net/man/1/rsync

share|improve this answer
    
yes but once, unfortunately, it messed up a lots of things.. I wanted something basic I can control, like cp.. –  Tiutto Dec 15 '12 at 21:22
    
actually after long time.. I tried again rsync and it works quite well! –  Tiutto Dec 15 '12 at 21:53

Your Answer

 
discard

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