LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   rsync not working (https://www.linuxquestions.org/questions/linux-newbie-8/rsync-not-working-4175506329/)

rmcellig 05-28-2014 07:05 PM

rsync not working
 
I am going crazy with a problem that seems really easy to resolve. This code works fine:

Code:

rsync -av  /home/randy/chuo-radio-shows/  randy@192.168.2.18:/media/masterlps/chuo-radio-shows
This one here gets me the following error:

Code:

randy@watt0s:~$ rsync -av  /home/randy/chuo-radio-shows/  randy@192.168.2.14:/media/nic/chuo-radio-shows
sending incremental file list
rsync: mkdir "/media/nic/chuo-radio-shows" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at main.c(605) [Receiver=3.0.9]
rsync: connection unexpectedly closed (9 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(605) [sender=3.0.9]
randy@watt0s:~$

I have /media/nic as part of my fstab entry and it mounts fine. No problems at all. What could be causing the problem? What should I look at and post back?

lleb 05-28-2014 07:40 PM

is it mounted when you try to run the rsync command? if its not mounted before the rsync command, rsync will not mount it for you.

rmcellig 05-28-2014 08:06 PM

Yes. /media/nic is mounted. I can use the drive from pcmanfm with no problems.

potato_farmer 05-28-2014 11:17 PM

What happens when you run the following?
ls -la /media/nic/chuo-radio-shows

Or the following?
touch /media/nic/chuo-radio-shows/file

Also, when you run rsync, make sure to keep consistent with how you end your source and dest dirs. If you have a trailing slash for one, add a trailing slash for the other.

rmcellig 05-29-2014 06:09 AM

I tried with and without the trailing slash as well. Same thing.


Code:

randy@watt0s:~$ ls -la /media/nic/chuo-radio-shows
total 0
drwxrwxr-x  2 randy randy 0 May 28 19:51 .
drwxr-xr-x 45 randy randy 0 May 28 19:51 ..
randy@watt0s:~$




Code:

randy@watt0s:~$ touch /media/nic/chuo-radio-shows/file
randy@watt0s:~$ ls
chuo-radio-shows  Desktop  Documents  Downloads  Music  Pictures
randy@watt0s:~$ cd /
randy@watt0s:/$ ls
bin  cdrom  etc  initrd.img      lib        media  opt  root  sbin    srv  tmp  var      vmlinuz.old
boot  dev    home  initrd.img.old  lost+found  mnt    proc  run  selinux  sys  usr  vmlinuz
randy@watt0s:/$ cd media/nic
randy@watt0s:/media/nic$ ls
chuo-radio-shows  Desktop    Downloads      Music  Pictures  systeminfo-Wednesday-03-July-2013-06:45:13.txt  Videos
CrashPlan.desktop  Documents  Komodo-Edit-8  Other  Public    Templates
randy@watt0s:/media/nic$ cd chuo-radio-shows/
randy@watt0s:/media/nic/chuo-radio-shows$ ls
file
randy@watt0s:/media/nic/chuo-radio-shows$


michaelk 05-29-2014 07:05 AM

So it appears that /media/nic is the mount point for /home/nic (or /home/randy) on 192.168.2.14. The rsync command posted does not use mount point in your fstab and would reference the path /media/nic/chuo-radio-shows on 192.168.2.14 which probably does not exist.

You can rsync between mounted directories or use the actual path on 192.168.2.14.

potato_farmer 05-29-2014 10:40 AM

I should have clarified. I meant run these commands on the destination host (not the one you are running the rsync command on).

What happens when you run the following?
ls -la /media/nic/chuo-radio-shows

Or the following?
touch /media/nic/chuo-radio-shows/file

rmcellig 05-29-2014 11:32 AM

Code:

results

nicole@nicpc:~$ ls -la /media/nic/chuo-radio-shows
ls: cannot access /media/nic/chuo-radio-shows: No such file or directory
nicole@nicpc:~$ ls
chuo-radio-shows  Other
CrashPlan.desktop  Pictures
Desktop                  Public
Documents          systeminfo-Wednesday-03-July-2013-06:45:13.txt
Downloads          Templates
Komodo-Edit-8          Videos
Music
nicole@nicpc:~$ touch /media/nic/chuo-radio-shows/file
touch: cannot touch `/media/nic/chuo-radio-shows/file': No such file or directory

Wouldn't this be a normal response because the mount point for this computer is on my source machine? The Dell 3000, and not on the destination machine?

suicidaleggroll 05-29-2014 11:37 AM

The command you posted would copy all files from the directory /home/randy/chuo-radio-shows/ on your local machine to the directory /media/nic/chuo-radio-shows on 192.168.2.14. Since 192.168.2.14 does not have a /media/nic/chuo-radio-shows directory, the command fails.

So, what is it exactly that you're trying to accomplish here?

rmcellig 05-29-2014 11:46 AM

1 Attachment(s)
There are the three instances where I am using rsync. The first two work great. The last one doesn't.

Code:

#sync chuo-radio-shows folder
*/30 * * * * rsync -av  /home/randy/chuo-radio-shows/  randy@192.168.2.13:/media/mainserver_/chuo-radio-shows
*/30 * * * * rsync -av  /home/randy/chuo-radio-shows/  randy@192.168.2.18:/media/masterlps/chuo-radio-shows
*/30 * * * * rsync -av  /home/randy/chuo-radio-shows/  randy@192.168.2.14:/media/nic/chuo-radio-shows

Here is my fstab file on my Dell (Source machine)

Code:

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>  <type>  <options>      <dump>  <pass>
# / was on /dev/sda1 during installation
UUID=5d8299f1-890a-4149-a92a-71d9123006b7 /              ext4    errors=remount-ro 0      1
# swap was on /dev/sda3 during installation
UUID=6c800312-a0c3-4a70-b4b6-81b7afd78ad8 none            swap    sw              0      0
/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0      0

#mount samba share
//192.168.2.13/mainserver /media/mainserver cifs credentials=/home/randy/.smbcredentials,uid=1000,gid=1000,iocharset=utf8,sec=ntlm 0 0
//192.168.2.11/randymac /media/imac cifs credentials=/home/randy/.smbcredentials,uid=1000,gid=1000,iocharset=utf8,sec=ntlm 0 0
//192.168.2.18/dv6home /media/dv6 cifs credentials=/home/randy/.smbcredentials,uid=1000,gid=1000,iocharset=utf8,sec=ntlm 0 0
//192.168.2.18/masterlps /media/masterlps cifs credentials=/home/randy/.smbcredentials,uid=1000,gid=1000,iocharset=utf8,sec=ntlm 0 0
//192.168.2.14/home /media/nic cifs credentials=/home/randy/.smbnicole,uid=1000,gid=1000,iocharset=utf8,sec=ntlm 0 0


potato_farmer 05-29-2014 11:50 AM

It looks like you are mounting /media/nic from the destination to the source:
//192.168.2.14/home /media/nic cifs credentials=/home/randy/.smbnicole,uid=1000,gid=1000,iocharset=utf8,sec=ntlm 0 0

Try this instead:
rsync -av /home/randy/chuo-radio-shows/ /media/nic/chuo-radio-shows/

You already mounted it right? You don't need to have rsync go to the server and look for the path (that does not exist). You can simply copy from your local source to the mount point on the local source.

suicidaleggroll 05-29-2014 11:56 AM

Alright, it looks like you're just confused about how network shares (and perhaps mounting in general) work on Linux.

When you mount a network share, for example //192.168.2.14/home to /media/nic, the remote directory 192.168.2.14:/home becomes available locally at /media/nic. 192.168.2.14:/home/myfile can be accessed locally at /media/nic/myfile.

You seem to be combining the remote access and the local access verbage in your rsync call. If you want to sync /home/randy/chuo-radio-shows on your local machine to /home/chuo-radio-shows on 192.168.2.14, you can do it using either:
Code:

rsync -av /home/randy/chuo-radio-shows/ /media/nic/chuo-radio-shows/
OR
Code:

rsync -av /home/randy/chuo-radio-shows/ 192.168.2.14:/home/chuo-radio-shows/
The first one uses the cifs remote mount to do the transfer. The second one uses rsync's default remote transfer protocol (usually ssh) to do the transfer.

You CANNOT reference your LOCAL mount point on the REMOTE filesystem, however, which is what your earlier rsync command was attempting to do. There is no /media/nic/chuo-radio-shows on 192.168.2.14, it doesn't exist. /media/nic/ on your LOCAL filesystem is a remote mount of 192.168.2.14:/home, so when YOU reference /media/nic/chuo-radio-shows on your LOCAL filesystem, you're actually pointing to 192.168.2.14:/home/chuo-radio-shows.

You need to pick which way you want to reference the remote destination. Do you want to transfer through the CIFS mount? If so, use the first rsync syntax I provided above by pointing to the mount point on your local filesystem. Do you want to transfer through rsync's default remote transfer protocol (eg: ssh)? If so, use the second rsync syntax I provided above by pointing to the remote location on the remote machine directly.

Your first two commands are only working because of a fluke. Those directories just happened to exist there, either through some freak coincidence, or because you created them for some reason. They should all be failing like the third one is.

rmcellig 05-29-2014 12:09 PM

Hi suicidaleggroll,

Thanks so much for clearing this up. I will try out both methods you described and post back. I see exactly what you are talking about now and I understand! Wow! I love learning all about Linux even though my brain gets confused at times.

I have a question. When I set up my fstab for 192.168.14 does connect regardless of who the user(s) are at the other end or is this defined in the creadentials file I created and included in the fstab entry?

suicidaleggroll 05-29-2014 12:22 PM

The cifs entry in fstab will be mounted using the credentials you provide.

If these are all Linux systems though, I would highly suggest avoiding samba and cifs and just use NFS though. NFS will handle linux file access and user permissions much cleaner than samba will, since samba is built for sharing with windows systems (and the user permission hell that entails).

With NFS, just make sure your user "randy" has the same UID on all machines, and file ownership and permissions will cross over seamlessly.

rmcellig 05-29-2014 12:25 PM

Thanks! I just wanted to make sure that I had it rock solid clear in my head. I tried rsync out and it works fine now. Glad I went through this learning process. Thank you so much!!! :)


All times are GMT -5. The time now is 07:22 AM.