Use Git to perform daily backup

By | March 15, 2013

You can use git to perform scheduled backup for your file, for example, backup a site deploy. For example, I want to backup a site named MVC4

I use git + script + scheduled task to do the backup, the advantage of this approach is that:

  • Each backup can be compared for changes.
  • Save disk space since git uses a effective way for file storage.

And here’s how:

1. Create a bat file contains:

%systemroot%\system32\inetsrv\appcmd stop site /site.name:MVC4
cd "C:\WebDeploy\MVC4"
"C:\Program Files (x86)\Git\cmd\git.exe" add -A
"C:\Program Files (x86)\Git\cmd\git.exe" commit -m 'backup'
%systemroot%\system32\inetsrv\appcmd start site /site.name:MVC4

The first line and the last is to stop and restart the site because some files are being used which blocks the backup.

2. Create a schedule task running daily:

image

3. The backup result:

image1