rsync to copy folders local and remote - windows-7

I'm trying to copy a directory with files and folders to another directory, first locally to test, and then to a remote server. The tool that I must use is rsync, but after a lot of testing and reading the docs I can't make it work under Windows 7.
For example, when I try
rsync -av D:\source\ D:\dest\
I get the error The source and destination cannot both be remote.
When I try rysnc -av \source\ D:\dest\, I get Error: Failed to exec ssh: No such file or directory (2)
Do you know how can I get it to work?
Thank you.

Cygwin paths are different, to make them Unix-like. Use
rsync -av /cygdrive/d/source/ /cygdrive/d/dest/
D: is interpreted as a remote server called D

Gravedigger coming back to dig this up -
On my windows 8.1 machine it was running everything fine but5 on my Windows 7 machine I was having this same issue. Fixed it by editing vagrant's source -
For me it was here - C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.6.3\plugins\synced_folders\rsync\helper.rb
And I added cygdrive as a prefix and everything is going well -
if Vagrant::Util::Platform.windows?
# rsync for Windows expects cygwin style paths, always.
# Editing source is never fun, but it works : /
hostpath = "/cygdrive" + Vagrant::Util::Platform.cygwin_path(hostpath)
end

Related

rsync transfer to remote machine syntax for windows

I have to transfer (and keep synched) two folders through rsync.
My problem is I always get an error on the remote folder, which I double checked is correct and existing.
Command line I use is:
rsync -rtvIz --chmod=ugo=rwX /cygdrive/c/aus/testrsync/sync remote.server.intranet:/cygdrive/d/testrsync
Error I receive is:
rsync: Failed to exec ssh: No such file or directory (2)
The following command line, using a shared folder on remote DeltaCopy works fine:
rsync -rtvIz --chmod=ugo=rwX /cygdrive/c/aus/testrsync/sync remote.server.intranet::EBackup
It may depend upon exactly what version of rsync you are using on the server side but I don't specify /cygdrive paths for my server path. Using the rsync protocol at least I set the remote URI as rsync://MACHINE:/Dirname/Subdir but I do have to use /cygdrive type paths for the local paths. Then on the Windows server machine that hosts the rsyncd the rsyncd.conf cygwin style paths. eg:
[Builds]
comment = Automated build output
path = /cygdrive/e/Builds
read only = yes
list
This allows normal rsync uri's to be used by clients and the server can then translate these into something it can access on the local filesystem.

scp upload file: no such file or directory

I'm using ssh to connect with a linux server. I'm trying to upload a file from my own computer(windows7) to linux.
When I type scp Desktop/H5.txt xxUserNamexx#mumble-39.xxServerNamexxx:/u/private/
I got following error:
scp Desktop/H5.txt xxUserNamexx#mumble-39.xxxServerNamexxxx:/u/private/
Desktop/H5.txt: No such file or directory
I can guarantee the server name and the file directory is correct. It seems that scp cannot find my file on my local computer.
What's the default path? What path should I type if the file I'm intending to upload is on my desktop?
Thank you
winscp is a nice option to copy files from MS to *nix. Also pscp is useful. SCP have known issues when used between MS and nix. There seems to be some misunderstanding of folder structure by scp.
drap the H5.txt from desktop to you cmd windows, this can avoid you type the wrong path
In the future you could try using winscp when you're dealing with small files. Also I think a cygwin scp should work just fine.
The slashes are incorrect. On Windows, it should be (assuming you are running Command Prompt from your Home directory):
C:\Users\user> scp Desktop\H5.txt junjue#mumble-39.xxServerNamexxx:/u/j/u/junjue/private/

Rsync bash script and hard linking files

I am creating a bash script to backup my files with rsync.
Backups all come from a single directory.
I only want new or modified files to be backed up.
Currently, I am telling rsync to backup the dir, and to check the files compared to the last backup.
The way I am doing this is
THE_TIME=`date "+%Y-%m-%dT%H:%M:%S"`
rsync -aP --link-dest=/Backup/Current /usr/home/user/backup /Backup/Backup-$THE_TIME
rm -f /Backup/Current
ln -s /Backup/Backup-$THE_TIME /Backup/Current
I am pretty sure I have the syntax correct for this. Each backup will check against the "Current" folder, and upload only as necesary. It will then delete the Current folder, and re-create the symlink to the newest backup it just did.
I am getting an error when I run the script:
rsync: link "/Backup/Backup-2010-08-04-12:21:15/dgs1200series_manual_310.pdf"
=> /Backup/Current/dgs1200series_manual_310.pdf
failed: Operation not supported (45)
The host OS is running HFS filesystem, which supports hard linking. I am trying to figure out if something else is not supporting this, or if I have a problem in my code.
Thanks for any help
Edit:
I am able to create a hard link on my local machine.
I am also able to create a hard link on the remote server (when logged in locally)
I am NOT able to create a hard link on the remote server when mounted via afp. Even if both files exist on the server.
I am guessing this is a limitation of afp.
Just in case your command line is only an example: Be sure to always specify the link-dest directory with an absolute pathname! That’s something which took me quite some time to figure out …
Two things from the man page stand out that are worth checking:
If file's aren't linking, double-check their attributes. Also
check if some attributes are getting forced outside of rsync's
control, such a mount option that squishes root to a single
user, or mounts a removable drive with generic ownership (such
as OS X's “Ignore ownership on this volume” option).
and
Note that rsync versions prior to 2.6.1 had a bug that could
prevent --link-dest from working properly for a non-super-user
when -o was specified (or implied by -a). You can work-around
this bug by avoiding the -o option when sending to an old rsync.
Do you have the "ignore ownership" option turned on? What version of rsync do you have?
Also, have you tried manually creating a similar hardlink using ln at the command line?
I don't know if this is the same issue, but I know that rsync can't sync a file when the destination is a FAT32 partition and the filename has a ":" (colon) in it. [The source filesystem is ext3, and the destination is FAT32]
Try reconfiguring the date command so that it doesn't use a colon and see if that makes a difference.
e.g.
THE_TIME=`date "+%Y-%m-%dT%H_%_%S"`

Is there a way of listing the contents of the local directory in ftp?

lcd changes local directories.
ls lists files on remote directory.
What I would like is lls, to list files on local directory.
Is this possible?
I know I can always open another terminal to do this, but I'm lazy!
Yes:
!dir
The ! tells the client to run a local shell command. Tested this using both the Windows and Fedora default ftp clients. Note that the actual command may depend upon your OS, for example !ls may be necessary on other versions of Unix/Linux.
For what it's worth, the ! command is listed in the ftp client's help system:
ftp> help !
! escape to the shell
To list files locally use following command
!dir
Or use following command
!ls
Note: ! means locally not the remote.
lcd is working but !cd will not work and lpwd is not working but !pwd is working.

cwRsync ignores "nontsec" on Windows 7

I use cwRsync to sync up some file from Windows to Ubuntu. This process used to work fine on Vista, but since I upgraded to Windows7, I keep getting permission issues.
Some background... I did use to get the same permission issues on Vista, but that was resolved by using the CYGWIN=nontsec environment variable.
The premission problem
rsync: failed to modify permissions on xxx: Permission denied (13)
Since windows and UNIX file permissions differ, sync'ing files with windows permissions doesn't make sense. What rsync does is set the permission on the UNIX side to 0 (d---------). To prevent this, cygwin has the nontsec variable which instructs it to ignore the windows file permissions.
The problem is, on Windows7, nontsec appears not to have any effect.
re your solution, I had to make an adjustment to see it work for me - instead of your etc/fstab content, I used this content from the forum topic you reference:
none /cygdrive cygdrive binary,posix=0,user,noacl 0 0
I'm using cwRsync installer 4.0.3. I'm happy enough that it works for me but I can't offer a reason why, not being familiar enough with fstab syntax and options. Hopefully it adds something useful to someone else.
I figured out that it wasn't Windows 7 that was causing the issue. Rather, it was the new version of cwrsync that was ignoring the nontsec environment var. For cwRsync versions higher than 1.7, you need to use the noacl option. (see forum topic: No access to subfolders of RSYNC backup folder)
The solution involves creating an fstab file with the noacl option:
# In this example, my cwRsync dir is located at: "C:/Program Files (x86)/cwRsync"
# Filename: "C:/Program Files (x86)/cwRsync/etc/fstab"
C:/Program\040Files\040(x86)/cwRsync / ntfs override,binary,noacl 0 0
C:/Program\040Files\040(x86)/cwRsync/bin /usr/bin ntfs override,binary,noacl 0 0
And that's it! You can also remove the CYGWIN=nontsec env var since it's no longer used.
I was having this same problem copying from my Solaris based webhost down to my local PC. The PC permissions were wacked when the files were copied down. I setup the fstab file but no go.
In the end I realized that I was making a full path call to rsync.exe which meant my current directory was no picking up the etc folder I just created. To resolve this, I added these lines just above the call to the rsync command and it worked perfectly.
SET CWRSYNCHOME=%PROGRAMFILES%\CWRSYNC
c:
cd %CWRSYNCHOME%
Now my file permissions are correctly defaulting to the parent folder permissions without issues.
I just wanted to tag this onto this thread in case anyone else in the future is coming across the same issue I was.
This is now also addressed in the cwrsync FAQ:
http://www.itefix.no/i2/node/11324
I can also report the fix in the FAQ (and Raise's answer) worked for me as well.
I had the same problem, but none of the solutions worked for me, until I realized my destination folder was outside the rsync folder. (I wanted to rsync files from Linux to Windows.)
Here is what worked for me:
Create a subdir etc inside the cwRsync folder (that is, where the rsync.exe resides).
Create a file named fstab (no suffix) inside that folder.
Insert one line into that fstab file, be sure to have UNIX line endings!
none /cygdrive cygdrive binary,posix=0,user,noacl 0 0
Set environment:
SET CWRSYNCHOME=<cwRsync installation path>
SET HOME=<Directory to save user configuration files, like ssh known_hosts>
Before starting rsync.exe (this was the most important step in my case):
cd <Destination folder>
The SET HOME part is important for SSH, it will create a .ssh subfolder there with a known_hosts file.

Resources