Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I maintain a file server. I need to backup files that have changed in a period of time.

First i compressed up everything to 4gb files and backed up to dvd. But 7z that I was using

7z a -t7z /home/user/myfiles051413_proj.7z /home/share/projects -v4000m -m0=bzip2 -mmt=4

does not seem to have a way to zip modified files in the last 60 days and i am unsure how to pass that to a command sorta like this. I do not want to have to compress the whole folder and backup what is already backed up! (waste of space)

tar seems to work good with this

find /home/share/projects -mtime -60

and piping it into a command works too but spaces give me issues. Here is the command I am attempting to get work. Finding all files modified in last 60 days. then compressing them into 4gb files.

find /home/share/projects/ -mtime -60 | xargs tar -cvML 4194304 -f /home/user/myfiles`date '+%d%m%Y'_proj.tar`

at the moment it will run for a while then only have one small file in it. it prints out numerous files on the screen!


I have been playing with -print0

find /home/samba/shares/projects -mtime -60 -type f -print0| xargs tar -cvML 4194304 -f /home/samba/shares/bkup/`date '+%d%m%Y'_proj.tar` -T - --null

i get a whole lot of tar: de: Cannot stat: No such file or directory

share|improve this question

migrated from stackoverflow.com Jul 29 '13 at 16:27

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

    
To get around problems with spaces use the -print0 option in find. (and match xargs with -0). – Hennes Jul 29 '13 at 16:51
    
You're missing the -0 option to xargs. Also, if you want to add information, edit your question. This isn't a discussion forum. If you're going to add an answer, we expect it to provide a solution. – Daniel Beck Jul 29 '13 at 19:57

you have bug in last script with -print0 .

  1. you use xargs . not good idea because for lot of files xargs run tar twice or more.
  2. you use for tar -T - option. rights, but what for in this situation is xargs ?

simply remove xargs because it is unneeded. this grab all files from stdin and put to tar as arguments at the end. then tar -T option gets nothing on his stdin .

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .