Use Git to perform daily backup

by Weijie JIN on

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 /
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 /

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:


3. The backup result:


Previous post:

Next post: