Solved

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

Posted on 2013-05-13
5
235 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
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 27

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 27

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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). …
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
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…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

743 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

13 Experts available now in Live!

Get 1:1 Help Now