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

I have two huge folders that I want to rsync one after the other using one command.

Command 1:

rsync --compress /home/user/folder/  user@192.168.1.10:/home/user/a/folder

Command 2:

rsync --compress /home/user/folder2/  user@192.168.1.10:/home/user/b/folder2

Combined in One Command:

rsync --compress /home/user/folder/  user@192.168.1.10:/home/user/a/folder ; rsync --compress /home/user/b/folder2/  user@192.168.1.10:/home/user/folder2

After entering this command, I am prompted for the password for the remote server. That's fine. However, after the first command completes, I am again prompted for the same credentials (while I'm not around); therefore defeating my purpose of combining the commands.

I'd like to (1) perform one command, (2) leave, and (3) come back later to see that both jobs were completed one after the other.

Is this possible without scripting?

Edited: I modified my example to reflect that the destinations are not within the same parent folder.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

What about:

rsync --compress /home/user/folder2 /home/user/folder user@192.168.1.10:/home/user/

it will do what you want.

The one you wrote with the semi-column just concatenates the two commands. It is normal that it asks the password.

Or if you really want to rsync it one after another than you can use ssh with key to avoid passwords asking.

share|improve this answer
    
The ssh key suggestion is an acceptable workaround, but the command you suggested only works when the two destinations are within the same folder. However, to be fair, my question didn't properly emphasize the scenario I intended. –  LonnieBest Feb 24 '13 at 13:14

Is there any reason you can't use an ssh key? That would the the normal approach to solving the password prompt issue (followed by expect if a key is not possible).

I hope you're running this in a protected session, using something like screen or tmux.

share|improve this answer
    
Yeah, as Stone also recommended, ssh keys do indeed overcome the inability to achieve this with a command. –  LonnieBest Feb 24 '13 at 16:21
    
Its a shame that the credentials provided (initially) don't authenticate the second statement (given that the joined commands are all entered at once). –  LonnieBest Feb 24 '13 at 16:31
    
Oh, and why are screen or tmux necessary versus "terminal" (in Ubuntu)? –  LonnieBest Feb 24 '13 at 16:33

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.