Solved

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

Posted on 2013-05-13
5
242 Views
Last Modified: 2013-05-31
rsync -ave "ssh -i /home/forms/.ssh/phobosRSA" --delete forms@phobos:/u4/minkaPics/ /minkaPics
0
Comment
Question by:Jason Yu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 125 total points
ID: 39163273
man rsync
DESCRIPTION
       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
       updated.
        -v, --verbose               increase verbosity
        -a, --archive               archive mode; same as -rlptgoD (no -H)
        -e, --rsh=COMMAND           specify the remote shell to use

man ssh
DESCRIPTION
     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).
0
 
LVL 21

Assisted Solution

by:Mazdajai
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

0
 
LVL 29

Assisted Solution

by:serialband
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.
0
 

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.
mountIt
if [ `echo $?` != "1" ]; then
conversion
echo -e "To:IT<$blokes>
From: $host<$shost@minkagroup.net>
Subject: Minka pic script completed
Images have been converted successfully" | /usr/sbin/sendmail $blokes
umount $mnt
fi

elif [ `hostname` = "deimos.minkagroup.net" ]; 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<$shost@minkagroup.net>
Subject: Minka Pic sync on $host Failed!
Minka Pic sync between Deimos and Phobos failed" | /usr/sbin/sendmail $blokes
fi
size-is-different.jpg
0
 
LVL 29

Assisted Solution

by:serialband
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
0

Featured Post

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

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

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
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.:
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

688 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