Here is a tiny backup script for daily file backup in a windows environment for a small project. This script zip the folders those are to be backed and renamed it in a dated manner. Also this script will delete the old backup as well. Here I’m using 30 days retention period for this server.
Tools to be used,
1. Download and install 7Z zip compression utility from here http://www.7-zip.org/
2. Add C:\Program Files\7-Zip path ins system path.
3. SQLbackupandFTP program used for MSSQL backup. I set a scheduler.Database backups will be copied to “D:\Backup\databases”
Source : C:\FTP\domain.com\public_html
Backup location : :\Backup\webfiles
for /F "tokens=1,2 eol=/ delims=/ " %%A in ('date /T') do set mm=%%B
for /F "tokens=1,2 delims=/ eol=/" %%A in ('echo %CDATE%') do set dd=%%B
for /F "tokens=2,3 delims=/ " %%A in ('echo %CDATE%') do set yyyy=%%B
rem "Backup the Mybackup files are moving to D drive..."
7z a -t7z D:\Backup\webfiles\mydomain-%today_date%.7z C:\FTP\domain.com\public_html
rem "Backup has been completed"
rem " Deleting the backup files those are 30 days aged"
forfiles /P D:\Backup\webfiles /s /D -30 /M *.zip /C " cmd /c del @path"
forfiles /P D:\Backup\databases /s /D -30 /M *.zip /C " cmd /c del @path"
rem " Removing the backup which is 30 days old....."