Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm attempting to back some stuff up from a server that runs an old version of rsync - for various reasons I can't just upgrade the software.

Usually, I'd use --files-from and give a list of files and directories to back up, but this version of rsync doesn't have that switch. Is there a way, with other switches, to make an older rsync behave the same way?

I've tried a combination of --include-from= --exclude=* but that looks to be insufficiently recursive (eg. /etc/* only backs up things directly below /etc).

share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

I suspect that xargs is your friend in this instance.

Completely untested:

 # cat file | xargs -IREPLACE rsync -v REPLACE server:/path

xargs will take data from stdin and add it to the commandline one parameter per input line until it fills the command line length, and then runs a separate command until all the input lines have been used up. This will mean that rsync could well run more than once. This shouldn't be a problem in this case, but could be with other commands.

Usually xargs just sticks the arguments on the end of the line, but with rsync you'd want to have the destination last, so we use the -I option to replace a string with the arguments. (This is the bit that's untested). I'm also a little unsure what rsync will do with the paths, so please test this carefully before using it in anger.

If you do have a problem with xargs, you could use something like:

for i in $(cat file); do rsync -v $i server:/path; done

If your file is larger, you probably want to use a while/read loop instead. This will be much slower as it will do a single file at a time.

share|improve this answer
    
It would be a problem if the rsync runs more than once, since some files will be copied that are meant to be excluded. –  Rory Jul 21 '09 at 10:37
    
Only if the list of files overlap with each other, i.e. if you had a directory and a list of files in that directory. –  David Pashley Jul 21 '09 at 11:25
add comment

If your includes/excludes aren't recursing, perhaps you haven't specified -r? If you're used to using --files-from then you might have gotten out of the habit.

Apart from that, giving the exact command you're using might help. include-from/exclude-from definitely recurse nicely for me.

share|improve this answer
add comment

Silly no nonsense solution I've had to use before on some servers when rsync alone doesn't want to place nice. Use tar to only grab files you want:

cat INCLUDES
/home/user/index.htm
/home/user/robots.txt

tar cf INCLUDES.tar INCLUDES
for file in `cat INCLUDES`; do tar -r --file=INCLUDES.tar $file; done

rsync -avzP INCLUDES.tar user@remoteHost.com:./remote_path

--- Now on remote server

mkdir INCLUDES
tar xf INCLUDES.tar -C ./INCLUDES
rsync -avzP INCLUDES/home/user/ /home/user/
share|improve this answer
add comment

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.