Files Contain Windows Invalid Characters Transferred from QNAP to Asustor Using rsync


I want to copy files from QNAP TS-119P II to Asustor AS-5102T directly. There are many solutions: including ftp, rsync, or mount a shared folder.In my case, rsync is the easiest solution.

TS-119P II runs QTS 4.3.3 while AS-5102T is ADM 2.7.1. Details steps might be different if you are using different firmware versions.

I will also talk about invalid characters in names and how ADM handle it. A must read for non-Windows users.

Setup rsync Server on Asustor

Enable Enable Rsync server on [Services] → [Rsync Server] tab and click [Apply].

Next, add a backup module which controls destination path and authentication in [Backup Modules] on the same tab. The Name will show up in TS-119P II and files will be copy to Path here.

If you want to authorize by account, create new users by [Manage Users] dialog. Click [Edit] on the back module. When you enable Authentication in [Backup Module] dialog, select them for this backup module.

Users created here are only for rsync. You won’t see them on [Access Control] in ADM.

Setup a Replication Job on QNAP

Open [Backup Station] → [Remote Replication] → [Rsync (File-Level Backup)] tab and click on [Create a Replication Job] to create a replication job.

In [Remote Replication] dialog, give it a name and click on [Settings] to setup Remote site. In [Settings] dialog, enter the IP and user of AS-5102T. If you didn’t enable Authentication in rsync server,  provide any ADM valid user who has read and write access. Otherwise, provide authorized user in the backup module mentioned in previous section. The [Test] button only verifies if the give IP has a live rsync server. It doesn’t do anything with authentication.

If the authentication is success, you may select the backup module name in rsync server in Destination folder. Put the TS-119P II source folder in Source folder. Click on [Add] to confirm. You cannot only one pair of them in a replication job. If you need more folders to replicate, create a separate job for each of them.

Rsyncing

Push the start icon next to the job in the tab to run this replication job immediately. If you want to run it regularly, click on [Backup frequency] button in [Remote Replication] dialog to schedule.

For files and folders already exist in destination path will be untouched unless there is the same file name from source. The file on destination will be replaced by file with the same name.

Invalid Characters in Names

When I am comparing contents on both sides, I notice a folder * Test  on source becomes _3AJDB~3 on destination on OSX. The former is accessible but the later is not from OSX. Strangely, it is displayed properly in [File Explorer] in ADM. Moving files inside the folder without problems but fail to change name by warning containing invalid characters.

If I rename this folder on ADM from OSX, it displayed properly on OSX but becomes  Test in [File Explorer] in ADM.

Anyway, it’s too wordy. Just take a look at the summary table.

Folders contains invalid characters created on QTS from OSX
QTS rsync from QTS on ADM QTS remote access from OSX ADM remote access from OSX
Display Correct Correct Correct Fail
Access Success Correct Correct Fail
Rename but keep invalid characters
Fail Fail Success and display correctly on QTS Success but display incorrectly on ADM

I think it is ADM who force to follow the rules explained in NTFS and ReFS Invalid Characters section in Invalid Characters in File Names on its ext4. It’s a good idea for Windows users but a potential problem to others – QTS keeps them while ADM won’t. They will be replaced by characters known by ADM but not QTS or OSX. It’s call mangling.

Why Mangling and How To Stop

8 days after this post being published and more tests have been done, I finally realized I made a big mistake!

On 5.4 Name Mangling and Case  of O’Reilly’s Using Samba:

Samba still has to remain backwards compatible with network clients who store files only in the 8.3 format, such as Windows for Workgroups. If a user creates a file on a share called antidisestablishmentarianism.txt, a Windows for Workgroups client couldn’t tell it apart from another file in the same directory called antidisease.txt. Like Windows 95/98 and Windows NT, Samba has to employ a special methodology of translating a long filename to an 8.3 filename in such a way that similar filenames will not cause collisions. This is called name mangling, and Samba deals with this in a manner that is similar, but not identical to, Windows 95 and its successors.

Although I have enable Enable Mac file service (AFP) in [Services] → [Mac OS X] → [File Service] tab, it is Samba displayed in Finder.I am using it to access ADM shared folders. That’s why my file names with Windows invalid characters are mangled.

There are two solutions: add mangled names = no in smb.conf or use AFP (Apple Filing Protocol) instead.

Fail to Stop Samba Mangling

In Special characters in Samba filenames on serverfault, we may add mangled names = no in [global] section to stop mangling in Linux.

Windows does not allow some characters in filenames that Unix does allow. Samba “mangles” the filenames to make them comply with Windows restrictions…

Adding “mangled names = no” to smb.conf solved this (thanks, Dennis Williamson).

But even you modify /volume0/usr/builtin/etc/samba/smb.conf and restart with [Services] → [Windows], it won’t work. Samba keep on mangling Windows invalid characters. It’s the same if you modify /etc/config/smb.conf in QTS. mangled names is always yes on both systems.

We have to try next solution.

BTW, if you put # in front of any options, they will be removed after Samba restarts.

More about configuration files may be found in Asustor ADM Configuration and Executable Files and QNAP QTS Configuration and Executable Files.

Show AFP Servers in Finder

Asustor Samba Shared Folder use the same Icon as QNAP AFP Shared Folder
Asustor Samba Shared Folder use the same Icon as QNAP AFP Shared Folder

On ADM, if you just enable Enable Mac file service (AFP) in [Services] → [Mac OS X] → [File Service] tab, you won’t see it in Finder. An AFP server will have (AFP) at the end of the server name.

You need to use [Connect to Server] dialog in Finder’s menu [Go] → [Connect to Server…] and type aftp://[IP of NAS] to choose AFP connect to ADM.

To display an AFP server on ADM in Finder, enable Advertise AFP service over Bonjour in [Services] → [Mac OS X] → [File Service] tab and give it a service name. It will be displayed with (AFP) after service name in Finder.

QTS don’t have this option and its AFP service is always displayed in Finder.

Conclusion

If there are only Windows in your network, use Samba. Once you have OSX, remember to use AFP from OSX to prevent mangling. rsync among NAS won’t mangle because they are not using Samba.

Reference

  1. Apple: Apple Filing Protocol Concepts
  2. Apple: OS X
  3. Asustor: AS-5102T
  4. Asustor: ADM 2.7
  5. Asustor ADM Configuration and Executable Files
  6. Invalid Characters in File Names
  7. O’Reilly: Using Samba: 5.4 Name Mangling and Case
  8. QNAP QTS Configuration and Executable Files
  9. QNAP: Downloads and other support for TS-119P II
  10. QNAP: QTS
  11. Samba
  12. serverfault: Special characters in Samba filenames
  13. Wiki: ext4
  14. Wiki: File Transfer Protocol
  15. Wiki: mount (Unix)
  16. Wiki: rsync

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.