can anyone explain what this command for, especially the part between " ".

Posted on 2013-05-13
Last Modified: 2013-05-31
rsync -ave "ssh -i /home/forms/.ssh/phobosRSA" --delete forms@phobos:/u4/minkaPics/ /minkaPics
Question by:Jason Yu
LVL 84

Accepted Solution

ozo earned 125 total points
ID: 39163273
man rsync
       rsync is a program that behaves in much the same way that rcp does, but
       has many more options and uses  the  rsync  remote-update  protocol  to
       greatly  speed  up  file  transfers  when the destination file is being
        -v, --verbose               increase verbosity
        -a, --archive               archive mode; same as -rlptgoD (no -H)
        -e, --rsh=COMMAND           specify the remote shell to use

man ssh
     ssh (SSH client) is a program for logging into a remote machine and for
     executing commands on a remote machine.  It is intended to replace rlogin
     and rsh, and provide secure encrypted communications between two
     untrusted hosts over an insecure network.  X11 connections and arbitrary
     TCP ports can also be forwarded over the secure channel.
     -i identity_file
             Selects a file from which the identity (private key) for RSA or
             DSA authentication is read.  The default is ~/.ssh/identity for
             protocol version 1, and ~/.ssh/id_rsa and ~/.ssh/id_dsa for pro-
             tocol version 2.  Identity files may also be specified on a per-
             host basis in the configuration file.  It is possible to have
             multiple -i options (and multiple identities specified in config-
             uration files).
LVL 21

Assisted Solution

Mazdajai earned 125 total points
ID: 39163320
Compare the directories and files on phobos and delete them on destination.

--delete                delete extraneous files from dest dirs

Open in new window

LVL 28

Assisted Solution

serialband earned 250 total points
ID: 39166480
In more layman's terms, rsync is the tool used to copy or synchronize files.  It's basically mirroring the minkaPics folders from a system named phobos to the local system using the ssh key in the forms account.

The -e "ssh -i /home/forms/.ssh/phobosRSA" portion of the rsync command tells it to load the current (forms) user's ssh key, which I assume is passwordless, so that it doesn't prompt for a password.  Otherwise, a shorter command could be used with an rsync server that's been set up.

rsync -av --delete forms@phobos:/u4/minkaPics/ /minkaPics

You can also use the -e option to force it to use ssh with options to change ports, or use another ssh account.

The --delete option forces files to be deleted on the destination if it no longer exists at the source.  This allows rsync to basically mirror or duplicate the folder.

Author Comment

by:Jason Yu
ID: 39175827
hi, all, thanks for your replies.

I tried to fine tune this script and run it for two folders under /minkaPics.

However, after check the folders' sizes, they showed different size on the original server and destination server. Could you guys help me take a look?

Thank you.


## This is the start of the script. It will mount the nfs drive then start the conversion.
if [ `echo $?` != "1" ]; then
echo -e "To:IT<$blokes>
From: $host<$>
Subject: Minka pic script completed
Images have been converted successfully" | /usr/sbin/sendmail $blokes
umount $mnt

elif [ `hostname` = "" ]; then

#This script syncs the phobos:/u4/minkaPics folder with the local /u1/minkaPics folder.
#If any files are deleted off of phobos then they will also be removed from the local system.

rsync -ave "ssh -i /home/forms/.ssh/phobosRSA" --delete forms@phobos:/u4/minkaPics/medium /minkaPics/medium
rsync -ave "ssh -i /home/forms/.ssh/phobosRSA" --delete forms@phobos:/u4/minkaPics/small /minkaPics/small
if [ `echo $?` != "0" ]; then
echo -e "To:IT<$blokes>
From: $host<$>
Subject: Minka Pic sync on $host Failed!
Minka Pic sync between Deimos and Phobos failed" | /usr/sbin/sendmail $blokes
LVL 28

Assisted Solution

serialband earned 250 total points
ID: 39176044
Have you tried to just run the rsync commands manually?  Cut and paste the rsync commands from the script and run it at the terminal to see what happens

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now