LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-19-2015, 11:14 AM   #16
tearsforhari
Member
 
Registered: Mar 2015
Posts: 79

Original Poster
Rep: Reputation: Disabled

michaelk: Yes, I did enable sftp/ssh via the control panel in the NAS. I'm not following you on the rest about the .ssh keys. Right now, I am trying to rync as root, which works for some directories and not others as illustrated in my last post. However, I do anticipate that I will need to address the issue that you brought up about .ssh keys and will have to figure out how to automate this process by ssh-copy-id, later.
 
Old 05-19-2015, 11:23 AM   #17
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
You have two colons in your destination:
Code:
root@75.36.201.198::backups/system/MachineName/stage
This interfaces with the rsync daemon if I'm not mistaken, rather than going through ssh. So your arguments are conflicting and likely the rsync daemon doesn't have permission to write to /system/MachineName/stage/datafolder. If you want to go through ssh, you should only have one colon.

Also, where exactly are you trying to dump these files? ~/backups/system/MachineName/stage or /backups/system/MachineName/stage or /system/MachineName/stage or what?
 
Old 05-19-2015, 12:51 PM   #18
tearsforhari
Member
 
Registered: Mar 2015
Posts: 79

Original Poster
Rep: Reputation: Disabled
I found one of the problems with respect to the Time Stamp pertaining to the -a argument for Rsync:
rather than
>rsync -rav ....

I use
>rsync -rv ...

then it don't get the time stamp problem, and the Rsync works. Why did it work on the testfolder with -rav and not with the datafolder?
I even tried chmod 775 and 777 on the datafolder directory and it didn't work with -rav.

Last edited by tearsforhari; 05-19-2015 at 12:53 PM.
 
Old 05-19-2015, 12:57 PM   #19
tearsforhari
Member
 
Registered: Mar 2015
Posts: 79

Original Poster
Rep: Reputation: Disabled
suicidaleggroll:
if I try it with one colon, I get an error:
rsync: change_dir#3 "/root//backups/system/fd-lso-alice" failed: No such file or directory (2)


I am dumping it in the path /backups/system/MachineName/stage/datafolder on the NAS. It is really /Volume1/backups/system/MachineName/stage/datafolder, but the Rsync doesn't work with /Volume1
 
Old 05-19-2015, 01:49 PM   #20
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
That's because you're using ip:backups instead of ip:/backups. Relative vs absolute path.
 
Old 05-19-2015, 02:06 PM   #21
tearsforhari
Member
 
Registered: Mar 2015
Posts: 79

Original Poster
Rep: Reputation: Disabled
Yes, indeed. If I use the one semicolon with / AND include the volume1 directory:
>rsync -rav -e ssh --remove-source-files /home/ftp_user/stage/201503 root@IP:/volume1/backups/system/MachineName/stage
(fine)

Everything is good, even with the time stamps.

Or, to summarize, I can use:
>rsync -rv -e ssh --remove-source-files /home/ftp_user/stage/201503 root@IP::backups/system/MachineName/stage
(fine)

And everything works without the time stamps.


I'm having trouble automating the system with ssh-keygen and ssh-copy-id, though. Could you help?.
>ssh-keygen
(fine)
>ssh-copy-id root@IP:/backups/system/MachineName/stage
ssh: Could not resolve hostname IP:/backups/system/fd-lso-alice/stage: Name or service not known

Last edited by tearsforhari; 05-19-2015 at 02:39 PM.
 
Old 05-19-2015, 02:18 PM   #22
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,568

Rep: Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865
root@ip = root@75.36.201.198 and the keys are copied to the /root/.ssh directory which may or may not exist.
 
Old 05-19-2015, 02:38 PM   #23
tearsforhari
Member
 
Registered: Mar 2015
Posts: 79

Original Poster
Rep: Reputation: Disabled
Smile

I can ssh to the NAS as root, and there is indeed a directory /root that I can cd to. The .ssh file is empty. I got the following errors:

> ssh-copy-id root@75.36.201.198:/root/.ssh
ssh: Could not resolve hostname 75.36.201.198:/root/.ssh: Name or service not known
> ssh-copy-id root@75.36.201.198:/root
ssh: Could not resolve hostname 75.36.201.198:/root: Name or service not known

I can do the following that works:
> ssh-copy-id root@75.36.201.198
(fine)
>ssh root@75.36.201.198
(fine, no password needed)

I got it!! My problem was that I needed to invoke the following Rsync command:

>rsync -rav -e ssh --remove-source-files /home/ftp_user/stage/201503 root@75.36.201.198:/volume1/backups/system/MachineName/stage

and not the
>rsync -rv -e ssh --remove-source-files /home/ftp_user/stage/201503 root@75.36.201.198::backups/system/MachineName/stage

Last edited by tearsforhari; 05-19-2015 at 02:45 PM.
 
Old 05-19-2015, 02:45 PM   #24
tearsforhari
Member
 
Registered: Mar 2015
Posts: 79

Original Poster
Rep: Reputation: Disabled
Ok, one more follow-up question that was asked of me above:

Code:
Me: 2. How would I go about setting rsync and sshkey-gen on a third party linux box, where computer 3 accesses files from computer 1 and transfers them to computer 2?"
Code:
Evo: What do you mean by "setting"? Do you mean installing? If so, then by using the package manager for that system. Why does there need to be a 3rd computer in this scenario? Why can't you copy directly from computer 1 to computer 2?
Well, I probably could do it that way. But I am trying to re-create a shell script that used computer 3 to perform back ups of several other computers 1, 2, 4, 5 etc. How would my script be diiferent? Would I ssh-copy-id from computer 3 to all the other computers?

Last edited by tearsforhari; 05-19-2015 at 02:47 PM.
 
Old 05-21-2015, 04:30 AM   #25
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,568

Rep: Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865
Yes, you can copy the same key to the other computers.
 
Old 05-21-2015, 11:38 AM   #26
tearsforhari
Member
 
Registered: Mar 2015
Posts: 79

Original Poster
Rep: Reputation: Disabled
Help. I really need to rsync from computer1 to computer2, using computer3. I am trying to sync a directory in two computers. I tried the following command on computer3:
>rsync -rav -e ssh user1@75.35.111.205:/home user2@75.35.208.199:/volume1/backups/
The source and destination cannot both be remote.
rsync error: syntax or usage error (code 1) at main.c(1166) [Receiver=3.0.9]

Any suggestions?
 
Old 05-21-2015, 11:48 AM   #27
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
The error seems pretty self-explanatory to me
Quote:
The source and destination cannot both be remote.
Which means you can't do it. You have two options:
1) computer3 sshs into computer1 and tells it to rsync to computer2 directly (or vice versa)
2) computer3 rsyncs from computer1 to a temporary location on computer3, then rsyncs from that temporary location to computer2
 
Old 05-21-2015, 01:39 PM   #28
tearsforhari
Member
 
Registered: Mar 2015
Posts: 79

Original Poster
Rep: Reputation: Disabled
1. SCP on computer3 allows me to transfer files from computer1 to computer2. Can I modify this to mirror a directory tree without having to overwrite files each time?

2. Do you mean SSHFS? How would the command look like? (computer1 and computer2 cannot talk directly to one another)

3. Here's my attempt to use Rsync into two commands, which I would prefer to avoid:
>Rsync user1@host1:/datafolder /tmp
>Rsync -rav -e /tmp user2@host2

4. Here's something that I took off the web that sounds similar:
>SSHFS user1@host1:/datafolder /mnt
>rsync -rauv /mnt user2@host2:/mirrordatafolder

Last edited by tearsforhari; 05-21-2015 at 01:42 PM.
 
Old 05-21-2015, 02:12 PM   #29
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
1 - No, scp does not support that

2 - That's not what I mean, but sshfs could work too

3 - You're mixing up flags. There's no point in -a on the second rsync if it's not on the first, and without the recursive flag set on the first you'll skip all directories (-r is included in -a). You also have -e, but no argument for it. ssh is implied, unless you need to modify the ssh parameters just leave "-e ssh" off entirely. You also don't have a path for your destination.
Code:
rsync -av user1@host1:/datafolder /some/temporary/location
rsync -av /some/temporary/location user2@host2:/mirrordatafolder
4 - Yes sshfs could work too
Code:
sshfs user1@host1:/datafolder /some/temporary/location
rsync -av /some/temporary/location user2@host2:/mirrordatafolder
umount /some/temporary/location
Watch the trailing slash on the source location in rsync. Unlike most other Linux commands the presence/absence of that trailing slash DOES make a difference in rsync. I left it off in my examples, but you may need it, it all depends on your directory structure at the source and destination, and what, exactly, you intend to copy over.

Last edited by suicidaleggroll; 05-21-2015 at 02:14 PM.
 
Old 05-21-2015, 02:23 PM   #30
tearsforhari
Member
 
Registered: Mar 2015
Posts: 79

Original Poster
Rep: Reputation: Disabled
Could you write what you intended for SSHS in 2 above? Never heard of SSHS.

Thanks for the tip on Rsync. I take it that the trailing slash is needed when just copying files within the trailing folder, and without is copying the name of the folder and contents?

How could I put 3 or 4 into a cronjob? Shall I make a shell script containing the two or three commands? Little confused on how that would work in a cronjob.

Last edited by tearsforhari; 05-21-2015 at 03:14 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] rsync between two different servers astalavista2000 Linux - Server 7 12-13-2010 09:10 PM
how to rsync files on two servers that have two different file systems mrotsliah Linux - General 2 08-11-2010 03:29 PM
rsync can not rsync files with include filter... xiutuo Linux - Server 2 07-23-2010 02:10 AM
which is the better way to rsync files between web servers? cooljai Linux - Server 8 05-21-2010 11:32 PM
Could I run rsync to download files from a server without rsync daemon? Richard.Yang Linux - Software 1 09-18-2009 04:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration