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 simple backup shell script that runs daily at 1:00 AM. It uses rsync to copy twelve different directories onto my Windows computer's external hard drive. Here's an example:

rsync -a --delete-after --progress --stats "$HOME/Downloads" "/Volumes/Backups/MacBook Pro"

It used to work fine, but one day it kernel panicked. Then the next day. And then the next. I did some troubleshooting and found that the kernel panic only occurs when the "$HOME/Documents" directory is included in the list of directories to be backed up. But here's the bizarre thing: if I run the backup script manually, the script makes it all the way through without a kernel panic. Any ideas? Here's the report:

Sat Jun 23 01:05:10 2012
panic(cpu 4 caller 0xffffff80002c473a): Kernel trap at 0xffffff7f8081a348, type 14=page fault, registers:
CR0: 0x000000008001003b, CR2: 0xffffff802216a000, CR3: 0x00000001c4fd3077, CR4: 0x00000000000606e0
RAX: 0x0000000000000067, RBX: 0xffffff802216005c, RCX: 0xffffff801dee780a, RDX: 0x0000000000000000
RSP: 0xffffff80f05cbb60, RBP: 0xffffff80f05cbbc0, RSI: 0x0000000000000001, RDI: 0xffffff8022169fcc
R8:  0x0000000000000000, R9:  0x0000000000000000, R10: 0x80000001c4fd3077, R11: 0xffffff8023ffc800
R12: 0xffffff802216a000, R13: 0x0000000000000002, R14: 0x000000000000805c, R15: 0x0000000000000034
RFL: 0x0000000000010296, RIP: 0xffffff7f8081a348, CS:  0x0000000000000008, SS:  0x0000000000000010
CR2: 0xffffff802216a000, Error code: 0x0000000000000000, Faulting CPU: 0x4

Backtrace (CPU 4), Frame : Return Address
0xffffff80f05cb810 : 0xffffff8000220792 
0xffffff80f05cb890 : 0xffffff80002c473a 
0xffffff80f05cba40 : 0xffffff80002da0cd 
0xffffff80f05cba60 : 0xffffff7f8081a348 
0xffffff80f05cbbc0 : 0xffffff7f807fd83b 
0xffffff80f05cbc60 : 0xffffff7f807fd8fe 
0xffffff80f05cbcc0 : 0xffffff7f80804bd9 
0xffffff80f05cbd00 : 0xffffff80003192d0 
0xffffff80f05cbd30 : 0xffffff8000308911 
0xffffff80f05cbf50 : 0xffffff80005cd61b 
0xffffff80f05cbfb0 : 0xffffff80002daa13 
      Kernel Extensions in backtrace:
         com.apple.filesystems.smbfs(1.7.2)[82526DF2-3BDB-3898-BA94-F58C5D4E0E01]@0xffffff7f807f2000->0xffffff7f80826fff
            dependency: com.apple.kext.triggers(1.0)[B7CEC019-EA05-3FCB-9E1A-F1CB4A0B2669]@0xffffff7f807ed000

BSD process name corresponding to current thread: rsync

Mac OS version:
11E53

Kernel version:
Darwin Kernel Version 11.4.0: Mon Apr  9 19:32:15 PDT 2012; root:xnu-1699.26.8~1/RELEASE_X86_64
Kernel UUID: A8ED611D-FB0F-3729-8392-E7A32C5E7D74
System model name: MacBookPro8,2 (Mac-94245A3940C91C80)

System uptime in nanoseconds: 252434098601163
last loaded kext at 236423088215259: net.tunnelblick.tun    1.0 (addr 0xffffff7f80791000, size 32768)
last unloaded kext at 236897483051934: net.tunnelblick.tun  1.0 (addr 0xffffff7f80791000, size 24576)
loaded kexts:
org.virtualbox.kext.VBoxNetAdp  4.1.10
org.virtualbox.kext.VBoxNetFlt  4.1.10
org.virtualbox.kext.VBoxUSB 4.1.10
org.virtualbox.kext.VBoxDrv 4.1.10
com.apple.filesystems.smbfs 1.7.2
com.apple.driver.AppleHWSensor  1.9.5d0
com.apple.driver.AudioAUUC  1.59
com.apple.driver.AppleMikeyHIDDriver    122
com.apple.driver.AppleUpstreamUserClient    3.5.9
com.apple.driver.AppleMCCSControl   1.0.26
com.apple.driver.AppleHDA   2.2.0f3
com.apple.driver.AppleMikeyDriver   2.2.0f3
com.apple.driver.AppleIntelHD3000Graphics   7.1.8
com.apple.driver.AGPM   100.12.42
com.apple.kext.ATIFramebuffer   7.1.8
com.apple.driver.SMCMotionSensor    3.0.2d6
com.apple.driver.AppleSMCPDRC   5.0.0d0
com.apple.iokit.IOUserEthernet  1.0.0d1
com.apple.iokit.IOBluetoothSerialManager    4.0.5f11
com.apple.Dont_Steal_Mac_OS_X   7.0.0
com.apple.driver.AudioIPCDriver 1.2.2
com.apple.driver.AppleSMCLMU    2.0.1d2
com.apple.driver.AppleMuxControl    3.0.16
com.apple.driver.ACPI_SMC_PlatformPlugin    5.0.0d0
com.apple.ATIRadeonX3000    7.1.8
com.apple.driver.AppleLPC   1.5.8
com.apple.filesystems.autofs    3.0
com.apple.driver.BroadcomUSBBluetoothHCIController  4.0.5f11
com.apple.driver.AppleUSBTCButtons  225.2
com.apple.driver.AppleUSBTCKeyboard 225.2
com.apple.driver.AppleIRController  312
com.apple.AppleFSCompression.AppleFSCompressionTypeDataless 1.0.0d1
com.apple.AppleFSCompression.AppleFSCompressionTypeZlib 1.0.0d1
com.apple.BootCache 33
com.apple.iokit.SCSITaskUserClient  3.2.0
com.apple.driver.XsanFilter 404
com.apple.iokit.IOAHCISerialATAPI   2.0.3
com.apple.iokit.IOAHCIBlockStorage  2.0.3
com.apple.driver.AppleSDXC  1.2.0
com.apple.driver.AppleUSBHub    4.5.0
com.apple.driver.AppleFWOHCI    4.8.9
com.apple.driver.AirPort.Brcm4331   530.4.20
com.apple.iokit.AppleBCM5701Ethernet    3.1.2b2
com.apple.driver.AppleEFINVRAM  1.5.0
com.apple.driver.AppleAHCIPort  2.3.0
com.apple.driver.AppleSmartBatteryManager   161.0.0
com.apple.driver.AppleUSBEHCI   4.5.8
com.apple.driver.AppleACPIButtons   1.5
com.apple.driver.AppleRTC   1.5
com.apple.driver.AppleHPET  1.6
com.apple.driver.AppleSMBIOS    1.8
com.apple.driver.AppleACPIEC    1.5
com.apple.driver.AppleAPIC  1.5
com.apple.driver.AppleIntelCPUPowerManagementClient 193.0.0
com.apple.nke.applicationfirewall   3.2.30
com.apple.security.quarantine   1.3
com.apple.driver.AppleIntelCPUPowerManagement   193.0.0
com.apple.driver.DspFuncLib 2.2.0f3
com.apple.driver.AppleSMBusController   1.0.10d0
com.apple.iokit.IOSurface   80.0.2
com.apple.iokit.IOSerialFamily  10.0.5
com.apple.iokit.IOFireWireIP    2.2.4
com.apple.iokit.IOAudioFamily   1.8.6fc17
com.apple.kext.OSvKernDSPLib    1.3
com.apple.driver.AppleHDAController 2.2.0f3
com.apple.iokit.IOHDAFamily 2.2.0f3
com.apple.driver.ApplePolicyControl 3.0.16
com.apple.driver.AppleGraphicsControl   3.0.16
com.apple.driver.AppleSMC   3.1.3d8
com.apple.driver.IOPlatformPluginLegacy 5.0.0d0
com.apple.driver.AppleSMBusPCI  1.0.10d0
com.apple.driver.IOPlatformPluginFamily 5.1.0d17
com.apple.driver.AppleBacklightExpert   1.0.3
com.apple.iokit.IONDRVSupport   2.3.2
com.apple.kext.triggers 1.0
com.apple.kext.ATI6000Controller    7.1.8
com.apple.kext.ATISupport   7.1.8
com.apple.driver.AppleIntelSNBGraphicsFB    7.1.8
com.apple.iokit.IOGraphicsFamily    2.3.2
com.apple.driver.AppleUSBBluetoothHCIController 4.0.5f11
com.apple.iokit.IOBluetoothFamily   4.0.5f11
com.apple.driver.AppleThunderboltDPInAdapter    1.8.2
com.apple.driver.AppleThunderboltDPAdapterFamily    1.8.2
com.apple.driver.AppleThunderboltPCIDownAdapter 1.2.4
com.apple.driver.AppleUSBMultitouch 227.1
com.apple.iokit.IOUSBHIDDriver  4.4.5
com.apple.driver.AppleUSBMergeNub   4.5.3
com.apple.driver.AppleUSBComposite  4.5.8
com.apple.driver.CoreStorage    182.11.0
com.apple.iokit.IOSCSIMultimediaCommandsDevice  3.2.0
com.apple.iokit.IOBDStorageFamily   1.6
com.apple.iokit.IODVDStorageFamily  1.7
com.apple.iokit.IOCDStorageFamily   1.7
com.apple.iokit.IOSCSIArchitectureModelFamily   3.2.0
com.apple.driver.AppleThunderboltNHI    1.5.5
com.apple.iokit.IOThunderboltFamily 2.0.0
com.apple.iokit.IOUSBUserClient 4.5.8
com.apple.iokit.IOFireWireFamily    4.4.5
com.apple.iokit.IO80211Family   420.3
com.apple.iokit.IOEthernetAVBController 1.0.1b1
com.apple.iokit.IONetworkingFamily  2.1
com.apple.iokit.IOAHCIFamily    2.0.8
com.apple.iokit.IOUSBFamily 4.5.8
com.apple.driver.AppleEFIRuntime    1.5.0
com.apple.iokit.IOHIDFamily 1.7.1
com.apple.iokit.IOSMBusFamily   1.1
com.apple.security.sandbox  177.5
com.apple.kext.AppleMatch   1.0.0d1
com.apple.security.TMSafetyNet  7
com.apple.driver.DiskImages 331.6
com.apple.iokit.IOStorageFamily 1.7.1
com.apple.driver.AppleKeyStore  28.18
com.apple.driver.AppleACPIPlatform  1.5
com.apple.iokit.IOPCIFamily 2.6.8
com.apple.iokit.IOACPIFamily    1.4

EDIT: Here is the shell script I'm running:

#!/bin/bash

target_directory="/Volumes/Backups/MacBook Pro"

directories_to_back_up=(
    "$HOME/Desktop"
    "$HOME/Documents"
    "$HOME/Downloads"
    "$HOME/Pictures/Photo Booth Library"
    "$HOME/.filezilla"
    "$HOME/Library/Application Support/Firefox"
    "$HOME/Library/Application Support/TextMate"
    "$HOME/Library/Mail"
    "$HOME/Library/Preferences"
    "/Applications/MAMP/conf"
    "/Applications/MAMP/htdocs"
);

if [ -d "$target_directory" ]; then
    for directory in "${directories_to_back_up[@]}"
    do
        if [ -d "$directory" ]; then
            echo "The following backup will begin in 10 seconds:"
            echo
            echo "Source: \"$directory\""
            echo "Target: \"$target_directory\""
            sleep 10
            echo

            rsync -a --delete-after --progress --stats "$directory" "$target_directory"
        else
            echo "The following directory was not found:"
            echo
            echo "\"$directory\""
            echo
            echo "Therefore, it was not backed up."
        fi

        echo
        echo "----------------------------------------"
        echo
    done
else
    echo "The backup could not proceed because the following directory was not found:"
    echo
    echo "\"$target_directory\""
fi
share|improve this question
    
How is the script invoked, 1. manually, 2. on schedule? In other words which exact command is used to start, and how do you schedule running the script? –  Pro Backup Jun 28 '12 at 16:33
    
@ProBackup It's just a cron job: 0 1 * * * /Users/Nick/Documents/backup.sh. I run it manually using the same command. –  Nick Jun 29 '12 at 2:05
    
what is the content of the backup.sh file? Why use cron when launchd is the preferred mechanism in OS X (at least since 10.6) for launching scheduled tasks? –  Pro Backup Jun 29 '12 at 8:56
1  
I would start trying to launch the script via launchd using a user daemon job. Create the plist file. When job needs to run even when no users are logged in put it in in /Library/LaunchDaemons/. Two, $ sudo launchctl load -w /Library/LaunchDaemons/my.scheduled.backup.plist. There is a nice plist cron style example at apple.stackexchange.com/questions/820/… Note: Before editing the plist, unload it first. Then load it again after your edit is ready. –  Pro Backup Jun 29 '12 at 9:18
1  
Sorry that I can't answer and have to ask an additional question. Under which user account does your cron (job) run? Most likely root, but to be sure, that is why there is a difference between running as cron job and running the script interactive from your shell. –  Pro Backup Jun 29 '12 at 19:24
show 2 more comments

1 Answer 1

I notice you have VirtualBox kexts loaded. I assume you have a VM running during the backup. In the past few months I've had kernel panics (nowhere near consistent as yours), from varying apps, but I eventually realized they only happen if I have VMs running and a high CPU load (like rsync would create).

I have no idea why yet, but you could probably test that on your system.

Your rsync command looks OK. I second the comment that says you should use launchd rather than cron though. Cleaner, more reliable, and once you create the plist in the right place, you won't have to worry about accidentally running as root.

There's a nice app called Lingon that provides a GUI for launchd. Very nice to work with, even if you're comfortable editing plist files manually.

Also, make sure the shell you specify at the top of the script is the same as the shell you're using in Terminal. Doubtful that's it, but you never know.

share|improve this answer
    
I actually don't have any virtual machines running during the backup. I haven't used launchd before, but, to experiment, I commented out my cron job, put a plist file in ~/Library/LaunchAgents, and loaded it with launchctl. We'll see what happens. I'll report back. Thanks for your time! –  Nick Jul 1 '12 at 3:08
    
Having the script run via launchd didn't prove to make any difference. I ended up fixing the problem by deleting a folder full of icons (I think there were around 18,000 or something crazy like that). I don't think there was anything about the icons themselves causing the problem. I think it was just the fact that rsync was dealing with so many files. Still, it seems strange that this would happen. Any other thoughts? –  Nick Jul 10 '12 at 2:28
2  
The backtrace contains the com.apple.filesystems.smbfs kext - this is the kext for connecting to samba/windows network shares. If the backup destination is such a network share, I could imagine that you've found a bug in handling more than X thousand files on a windows share. –  pmdj Aug 4 '12 at 19:27
    
@pmjordan The only flaw in that theory is that the script worked fine when run manually –  Nick Oct 11 '12 at 3:33
add comment

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.