I'd like to be able to access a Linux partition through cygwin on Windows. My purpose is to backup data from a Linux server to my home computer running Windows 7. Right now it mostly works, except when there's files with invalid characters or if there are multiple files with the same letters but different case.

  • How are you accessing the partition? Via a samba server on the Linux box? – ak2 Apr 15 '12 at 19:18
  • 1
    I'm essentially trying to back-up a Linux server that I'm accessing via SSH, to my Windows computer with an ext3 drive. Currently I'm just using rsync with cygwin, but then the issues above happen. – Mike Weir Apr 15 '12 at 20:47
  • Please show some examples of invalid characters. Cygwin 1.7 has special handling of characters such as : that aren't allowed in Windows filenames, mapping them to the "Unicode private use area". Are you using an older Cygwin version? – ak2 Apr 16 '12 at 2:09
  • The backslash character, namely, which doesn't get re-mapped. – Mike Weir Apr 16 '12 at 2:41

What I do is use a VirtualBox. This can be done in two ways,

  1. Store your data in VMDK files
    • this is pretty simple and safe; you can also keep different sized VMDK files for your backups
  2. Create a RAW disk access to a actual EXT3 partition on your HDD
    • be warned that this is a tricky way and you can easily break your ext3 partition
      (particularly if you use suspend or hibernate while it is mounted)
    • and, don't try to mount your Windows boot partition RAW in write-mode, ever.

If you get interested in automation: VBoxManage lets you control the VM from command line.

  • I don't think the potential for damage to the ext3 filesystem is particularly great if you remember to mount it read-only. – Eroen Apr 15 '12 at 16:08
  • @Eroen, mounting the local partition read-only defeats the purpose of making it a backup target. – nik Apr 15 '12 at 16:09
  • As I understand it, OP wants to extract data from the ext3 filesystem. That might very well be an incorrect assumption, though. – Eroen Apr 15 '12 at 16:10
  • IMO, OP wants to backup data from Linux Server to his local Windows system and is troubled by the windows-file-name limitations. – nik Apr 15 '12 at 16:11
  • That's a valid stance, and makes more sense. Sorry about the noise. – Eroen Apr 15 '12 at 16:13

As I understand it, you want to make a backup by copying a complete directory tree to a different computer, file by file. This is admittedly one way of making a backup, but I would suggest a different approach, especially since it appears to work out badly in your case.

What I do myself (in principle), it to create tarballs of the files I want to back up locally on the Linux server and save them somewhere else through ssh (actually by sshfs, but no matter). This should eliminate problems with filenames as long as the tar implementation on the Linux server handles them.

You could do this by setting up cygwin with an ssh server for the Linux server to connect to, or with a command like

ssh $server "tar c -C /var/important ./" > backup.tar

run from cygwin on the computer you want to keep the backup on. You could also save the tarballs on the Linux server and transfer them afterwards.

If you want to reduce the amount of bandwidth and diskspace comsumed, I suggest using star in stead of gnu tar, and it's incremental mode, which lets you only include files modified after the previous backup. It will still not do the delta transfer of rsync, and several versions of files will take up disk space, though. On the other hand, a tarball is far simpler to compress efficiently (with xz or something) than a directory tree.

  • This is not an option, the data is 25 GB and spans 47,000 files. It would take forever if I didn't use rsync or something like it. Even using incremental mode, it'd still be a procedure that simply would take far too much time, and half the amount of space on my server. – Mike Weir Apr 15 '12 at 22:53

There's a registry setting determining whether the Windows kernel treats filenames as case-insensitive:

HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\kernel\obcaseinsensitive

Set that to 0 and reboot to allow files differing only in case. See also http://cygwin.com/cygwin-ug-net/using-specialnames.html#pathnames-casesensitive.

Cygwin 1.7 automatically maps characters such as : that aren't allowed in Windows filenames into the "Unicode private use area". The one big exception to this is the backslash, which it treats as a directory separator for the sake of Windows interoperability, so the only thing you can do about those is avoid them in Linux filenames, or of course use a different approach altogether.

  • This doesn't solve special characters, and this would be quite dangerous in other respects. – Mike Weir Apr 16 '12 at 2:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.