# How-To: Automatically back up your computer

This is something that everyone should do, so I'm linking it here and will add it to the IT Guy Toolkit sticky.

We've seen plenty of crazy ways to keep your precious data safe. Some people burn a few tons of DVDs, others make a montly habit of swapping hard drives into a safe location. In today's How-To we'll show you how to automatically keep your data backed up from your computer with ssh and rsync. Feel that? That's our warm comfy safe-data blankie. Check it out.

rsync is very, very handy.

I do use RSYNC on my linux boxes but I use Robocopy on Windows.

Pathnames may and will vary for your own needs but you should get the majority of it from these.

First on the local PCs, I run this .cmd/.bat file (ignore line wraps and in this script I'm backing up the Favorites, the My Documents, the Outlook Express and Outlook 2003 store locations):

:: backup.cmd

@Echo off

:: Set your Robocopy (2003) location here.
Set Roboloc=C:\WINDOWS\system32\Robocopy.exe

:: Set your log output folder location here.
Set OutputDir=%WinDir%\Logs

For /F "tokens=1,2,3 delims=: " %%i in ('Time /T') do Set Timev=%%i-%%jm

:: Configure log location
for /F "tokens=2,3,4 delims=/ " %%i in ("%Date%") do set LogName=%%k-%%i-%%j_%Timev%

Set LogLoc=%OutputDir%\%LogName%

"%ROBOLOC%" "\\yourlocalpcname\c$\Documents and Settings\youruserprofile\My Documents" "\\yourserver-safelocation\Users\youruserprofile\Backup\My Documents" /E /NP /FFT /TEE /COPY:DATSOU /PURGE /R:1 /W:1 /LOG+:"%LogLoc%_Documents.txt" "%ROBOLOC%" "\\yourlocalpcname\c$\Documents and Settings\youruserprofile\Local Settings\Application Data\Microsoft\Outlook Express" "\\yourserver-safelocation\Users\youruserprofile\Backup\OLE\Store" /E /NP /FFT /TEE /COPY:DATSOU /PURGE /R:1 /W:1 /LOG+:"%LogLoc%_OLE-Store.txt"
"%ROBOLOC%" "\\yourlocalpcname\c$\Documents and Settings\youruserprofile\Favorites" "\\yourserver-safelocation\Users\youruserprofile\Backup\Favorites" /E /NP /FFT /TEE /COPY:DATSOU /PURGE /R:1 /W:1 /LOG+:"%LogLoc%_Favorites.txt" "%ROBOLOC%" "\\yourlocalpcname\c$\Documents and Settings\youruserprofile\Local Settings\Application Data\Microsoft\Outlook" "\\yourserver-safelocation\Users\youruserprofile\Backup\OL2K3" /E /NP /FFT /TEE /COPY:DATSOU /PURGE /R:1 /W:1 /LOG+:"%LogLoc%_OL2K3-Store.txt"

Goto :EOF

On my server with where everyone has their 'home' drive and where the shared folder is also hosted I run this robocopy script (this runs an hour after the local PCs run their scripts so it backs it all up) and it backs everything up to an external drive (it could just as well back everything up to another PC or another internal drive but this works for me since in a disaster I can grab the external and go). Anyway, here's the script, again ignore line wrap and this one relies on a text file named "shares.txt" that has the name of the shares to copy:

@echo off

:: Begin Script - Name = RoboCpy-NPurge.cmd
:: Run Robocopy as a backup utility but not purge deleted items on destination.
:: 10/23/2006 Ver 1.0

:: Set your Robocopy (2003) location here.
Set Roboloc=C:\WINDOWS\system32\Robocopy.exe

:: Set your log output folder location here.
Set OutputDir=\\SVR\path\to\backup\Logs

:: Set your share list location here.
Set ShareList=\\SVR\path\to\Shares.txt

:: Set your source server location here (You don't put the full path here, just the path up to the 'shares' in the .txt file for instance \\server\d\$.
Set SourceSrvr=SVR\path\above\shares

:: Set your destination server location here.
Set DestSrvr=SVR\path\to\destination

:: Note: Shares with spaces in share names are supported by this script.
:: However, shares with ampersands "&" in the share name are not.

::*************************************************
:: See Robocopy code below to modify Robocopy options
::*************************************************

For /F "tokens=*" %%i in (%ShareList%) do (Set Share=%%i) & (Call :runit)

::Run ends here
@Title Robocopy Run Completed

Goto :EOF

:runit

@Title %Share% copy in progress

For /F "tokens=1,2,3 delims=: " %%i in ('Time /T') do Set Timev=%%i-%%jm

:: Configure log location
for /F "tokens=2,3,4 delims=/ " %%i in ("%Date%") do set LogName=%%k-%%i-%%j_%Timev%_%Share%.txt

Set LogLoc=%OutputDir%\%LogName%

:: ******* Modify Robocopy options here **********************

"%ROBOLOC%" "\\%SourceSrvr%\%Share%" "\\%DestSrvr%\%Share%" /E /NP /FFT /TEE /COPY:DATSOU /R:1 /W:1 /LOG+:"%LogLoc%"

Goto :EOF

I run a variant of the server backup script on the last day of the month which does do the purge option. I could probably do this everynight since I run volume shadowcopy but why tempt fate?

Of course there is an even easier way, it was covered in this months Technet magazine and that's by using the XP PowerToy 'SyncToy'. Read that here.

I've been using Robocopy onto a Samba server, but I think the DST change got it all confused. I'll have to check out SyncToy, though!

doihaveto wrote:

I've been using Robocopy onto a Samba server, but I think the DST change got it all confused. I'll have to check out SyncToy, though!

Make sure your samba box has the right TZ info. My two here at home are FC3 and were set to Vancouver BC as the timezone. FC3 was patched with the DST but not the Canadian TZ's; Canadia hadn't yet agreed to follow and of course RH only updates FC versions for 6-12 months. The main box is always on and on a KVM so it was easy to go into gnome and change the timezone to US LA. I had to pull the other one out of the garage, let it warm up to room temp and turn it on to make the same changes (I can do some things from the terminal in linux but changing TZ's isn't one of them) and then put back out into the garage.

There's a nice program called "unison" I use to keep my laptop and desktop in sync. It has the distinct advantage of being pretty idiot proof.

This reminds me of something I've been thinking about lately. You know how with just about any broadband connection, they give you a free chunk of webspace with ftp access? Almost nobody uses it. What if an app were to run as a local service, and upon entering credentials and paths/folders to backup, perform a daily/hourly/etc backup of files? Anyone know of such an app? Most backup services use their own servers and charge fees. This could be free. I feel like I've posted about this before, but I may have drank those brain cells away.

baggachipz wrote:

This reminds me of something I've been thinking about lately. You know how with just about any broadband connection, they give you a free chunk of webspace with ftp access? Almost nobody uses it. What if an app were to run as a local service, and upon entering credentials and paths/folders to backup, perform a daily/hourly/etc backup of files? Anyone know of such an app? Most backup services use their own servers and charge fees. This could be free. I feel like I've posted about this before, but I may have drank those brain cells away.

Something like that would be easy to batch script. However, I know *I* wouldn't put my information f that level on my BB provider's network.

baggachipz wrote:

This reminds me of something I've been thinking about lately. You know how with just about any broadband connection, they give you a free chunk of webspace with ftp access? Almost nobody uses it. What if an app were to run as a local service, and upon entering credentials and paths/folders to backup, perform a daily/hourly/etc backup of files? Anyone know of such an app? Most backup services use their own servers and charge fees. This could be free. I feel like I've posted about this before, but I may have drank those brain cells away.

It's relatively trivial to write something like that, and you could encrypt it all if you wanted to.

ChrisGwinn wrote:
baggachipz wrote:

This reminds me of something I've been thinking about lately. You know how with just about any broadband connection, they give you a free chunk of webspace with ftp access? Almost nobody uses it. What if an app were to run as a local service, and upon entering credentials and paths/folders to backup, perform a daily/hourly/etc backup of files? Anyone know of such an app? Most backup services use their own servers and charge fees. This could be free. I feel like I've posted about this before, but I may have drank those brain cells away.

It's relatively trivial to write something like that, and you could encrypt it all if you wanted to.

That's what I was thinking. Common dialog box, encryption library, checksums of files to determine changes, ftp (maybe even sftp if the host allows), make it easy, and the average user has a free and robust backup package. If the internet has taught me anything, it's that giving away free stuff makes you rich. Nobody's heard of such an app?

There's also Mozy.