Posted On March 31, 2019

Dump Folder Archival Script

kimconnect 0 comments
blog.KimConnect.com >> Codes >> Dump Folder Archival Script
Requirements:
- Zip any .BAK files that are over 7 days
- Delete any zip files that have been generated 12 months ago

Solution:
- Install 7zip: https://7-zip.org/download.html
- Add C:\Program Files\7-Zip into Windows environmental path
- Create this batch file :
-------------------- cleanupbackups.bat ---------------------
@echo off
:: set folder path
set dump_path="D:\backups"

:: set min age of files and folders to compress
set max_days="7"

:: set max days of archive to maintain
:: set max_archived="358"

:: compress files from %dump_path%
forfiles -s -p %dump_path% -m *.bak -d -%max_days% -c "cmd /c 7z a -t7z @path.7z @path -ms -mmt"

:: remove files from %dump_path%
set dump_path="D:\backups"
forfiles -s -p %dump_path% -m *.bak -d -%max_days% -c "cmd /c del /q @path"

:: prune archive
set dump_path="D:\backups"
forfiles -s -p %dump_path% -m *.7z -d -%max_archiveds% -c "cmd /c del /q @path"

------------------------------------------------------------------
- Set Scheduled Tasks to call this batch file daily at 12:00 AM

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

BASH: Basic AWK Training

At first, AWK resembles the first three letter of 'awkward'. Nope, it's a scripting language…

Excel Comma Delimited CSV with Quotes

Option ExplicitSub MakeFile()Dim rng As RangeDim NumR As LongDim NumC As LongDim CountR As LongDim…

Mods to Zencart

Important Mods to Zencart OC GOLD® setup:   Zens Footer copyright info is moded at…