Skip to content

Instantly share code, notes, and snippets.

@kingbin
Created September 2, 2011 14:50
Show Gist options
  • Save kingbin/1188808 to your computer and use it in GitHub Desktop.
Save kingbin/1188808 to your computer and use it in GitHub Desktop.
windows quick script, backup contents of folder and retain for 30 days.
xcopy "c:\DIR_TO_BKUP\*.*" c:\Backup\*.* /e /h /r /y
7za a -tzip ourdatafile.zip "c:\Backup"
rename ourdatafile.zip ourdatafile.%Date:~-4,4%%Date:~-10,2%%Date:~-7,2%.zip
move ourdatafile.%Date:~-4,4%%Date:~-10,2%%Date:~-7,2%.zip "c:\ProgramData\bkups"
forfiles -p "c:\ProgramData\bkups" -s -m *.* -d 30 -c "cmd /c del @path"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment