Tag Archives: wakeonlan

Backing up Windows User’s to Folders to a Linux File Server

Robust File Copy for Windows

robocopy.exe available as part of rktools <-download page, can be used to copy files across the network to a Linux machine into a folder setup using Samba.

The DOS batch file below is called serverbackup.bat on my machine. It can start the Linux server using wolcmd <-download page, from Depicus.com and will copy a users folder to a folder on the server and creates a log file C:\tools\backup.log, then it shuts down the Windows PC with a 120 second delay. This delay is mostly there for testing. If the robocopy command goes belly up, the PC will try to jump right to the shutdown, which makes troubleshooting difficult. So leaving a delay is helpful as one can abort a shutdown by executing…

shutdown /a

…from the command line in Windows to stop the machine from shutting down.

I had to review how robocopy worked before deploying it in a backup script and I found an exact example of what I was looking for on Jacob Surland’s photography blog Caught in Pixels. I reviewed his post How to create a backup script using Robocopy before writing the serverbackup.bat script. I have the script downloadable here named serverbackup.bat, rename and modify as needed.

REM Wake Server, if it is already on, no harm done. It takes about 17 secs for server to start so REM robocopy will get an error and should keep retrying
REM run Depicus Wake on Lan from Command Line. Validated, Works!
 wolcmd yourmacaddr localserveripaddr 9
REM Copy User folder to \files\user on server via Samba links
 REM /MIR = purge files from dest. that do not exists in source
 REM /M Copy Archiveable files & reset attribute - not using this yet!!!
 REM /XA:SH exclude system and hidden important for user space
 REM /FFT fixes timing up for LINUX assumes FAT file times ( 2 sec granularity)
robocopy "C:\Documents and Settings\Erick_2" \\UBUNTUSERVER\Erick_Backup /MIR /XA:SH /XJ /FFT /W:1 /R:5 /LOG:C:\tools\backup.log
REM Shutdown PC when backups are done
shutdown -s -f -t 120

So far it works….


Windows Server 2003 Resource Kit Tools aka rktools

Depicus wolcmd download page

How to create a backup script using Robocopy


Wake On LAN via Ubuntu Linux

Wake on LAN (WOL), works great, sometimes it is a bit tricky to configure. With Linux, the client that sends the magic packet requires etherwake and the unit to be waked requires ethtool to be installed. Ethtool configures the OS to actually boot on the Network Interface Card NIC’s command. The NIC has to support Wake on LAN and the BIOS has to be set up to use it.

Installing etherwake…

sudo aptitude install etherwake

Installing this package actually installs both etherwake and wakeonlan. To wake the computer….

wakeonlan MAC-Address-Here


etherwake MAC-Address-Here

MAC Address

MAC Address, aka Physical Address of a Linux machines NIC can be found by executing ifconfig. In Windows, you can use ipconfig /all.




sudo apt-get install ethtool

Use for eth0, enabling WOL…

sudo ethtool -s eth0 wol g

To check if the system is armed for WOL, run…

sudo ethtool eth0

Towards the bottom you should see

Supports wake on: g
Wake on : g

On my PC, I noticed that once it is waked. It is necessary to run…

sudo ethtool -s eth0 wol g

To re-arm the WOL, every time it is remote waked.

I will write a bash script to shutdown the server. It will execute…

sudo ethtool -s eth0 wol g
sudo shutdown -P now

Ensuring that when I power the server down remotely, it will be armed for WOL.

Better than that I found out by looking online while researching how to auto-suspend the server, this little piece…

Create “/etc/udev/rules.d/50-wol.rules” with the following contents:

ACTION=="add", SUBSYSTEM=="net", KERNEL=="eth*", RUN+="/usr/bin/ethtool -s %k wol g"

Check the syslog after creating it, errors will appear there if you spelled something wrong or whatnot.

tail /var/log/syslog

but as of now, no errors, but not setting wol g either. Still trouble shooting.

I found this piece at …


The article talks about auto-suspending. But I found another article on auto-suspending that requires only a simple bash script that I have placed in /etc/cron.hourly but the article


does not give you the conf file, but it references another article in German


that does have a conf file and it seems to work, at least it runs. I have yet to see if it actually will auto-suspend! I am working on it right now and will post an entire write up when the bugs are worked out.


Remote vs Local

The first try most likely be on your own LAN. To do it for real remotely requires setting up your router to forward ports. I had to set it to forward port 7 and 9 to the outside world. Then it is a matter of sending a magic packet to the ISP address that your router reports of a FQDN ( Fully Qualified Domain Name), remotely I had to have the bit mask set to when using a utility on a website. Locally I noticed ( broadcast ) worked.


I read a bit about WOL here before attempting to set it up.