Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I have a script running by a LaunchAgent to sync a directory with a remote share.

This script is fairly simple, I'll include it here just so nobody suspects the script.

#!/bin/bash
# Hjälpskript för att ta backup.
# Endast för Mac OS, kommandon som stat, date och nc har annat syntax
# på Linux.
# Av Stefan Midjich

# REDIGERA DEN HÄR SÖKVÄGEN
backupTarget='/Volumes/myuser'

# REDIGERA ENDAST HÄR UNDER OM DU VET VAD DU GÖR
destinationFormat="sync" # backar som standard till YYYY-MM kataloger, en för varje månad
rsyncPort=22 # som standard antar vi att rsync använder ssh på port 22
purge=0 # som standard rensas inget gammalt
purgeDate='-2m' # standard: idag minus 2 månader
hostPattern='^([^:]+):(\/?.*)' # matcha värdnamn och sökväg från backupTarget

# Avsluta direkt om mål-katalogen inte existerar
if [[ ! "$backupTarget" =~ $hostPattern && ! -d "$backupTarget" ]]; then
    echo "Backup target looks like directory that is not found" 1>&2
    exit 1;
elif [ -n "${BASH_REMATCH[1]}" ]; then
    # Här har vi hittat vad som ser ut att vara ett värdnamn i backupTarget.
    # Så vi ska kontrollera att värden går att kontakta.
    remoteHost=${BASH_REMATCH[1]}
    if ! nc -z -w 5 "$remoteHost" $rsyncPort >/dev/null 2>&1; then
            echo "Can't connect to target host on port $rsyncPort" 1>&2
            exit 1
    fi
fi

# Ta backup av samtliga argument som är
# existerande kataloger.
for syncDir in $@; do
    if [ -d "$syncDir" ]; then
            # Lägg till --delete efter -a om rsync även ska radera i
            # destinationskatalogen. Annars sparas allt gammalt som raderas i
            # källkatalogen.
            rsync --exclude 'Microsoft *' -aS "$syncDir" "${backupTarget}/$destinationFormat/"
    fi
done

# Rensa allt som är äldre än purgeDate endast
# om purge är högre än 0.
if (($purge >= 1)); then
    purgeTime=$(date -v"$purgeDate" '+%s')
    for targetDir in "${backupTarget}/*"; do
            lastModified=$(stat -f '%m' "$targetDir")
            if (($lastModified < $purgeTime)); then rm -rf "$targetDir"; fi
    done
fi

And it launches from this LaunchAgent that is installed into ~/Library/LaunchAgents.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>org.myuser.syncDir</string>
    <key>ProgramArguments</key>
    <array>
            <string>/Users/myuser/bin/syncDir.sh</string>
            <string>/Users/myuser/Documents</string>
    </array>
    <key>WatchPaths</key>
    <array>
            <string>/Users/myuser/Documents</string>
            <string>/Volumes</string>
    </array>
</dict>
</plist>

This system has been working for a while now but ever since the user upgraded to Mavericks they've been having problems with any file being synced having the hidden attribute set at sync.

So the file is visible in Finder when it is being edited, but once it has synced over to the share it receives the hidden-attribute on the share and can no longer be seen when browsing the share in Finder.

Only using the shell can it be seen, also ls -O shows it has the hidden-attribute.

Connecting to the same SMB2 share using a Windows PC I can see all the files, so this hidden attribute is only in Mavericks. I can also un-hide the files from a Windows PC, which is even more weird.

The files that are hidden on Mavericks are shown on the Windows client as having a slightly different color, until I unset the hidden flag on them and they return to normal on both Windows client and Mavericks.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Apparently the issue was with how the share was mounted, smb:// caused the hidden-problem while cifs:// in the path worked well.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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