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

WordPress: Gold Price Widget CSS

Here's a sample of CSS Code to customize the display of the WordPress' Gold Pricing…

PowerShell: Copy SMB Share Permissions from Legacy Sources

Scenario:Windows 2008 File Servers migration lacks a built-in function to clone Share Permissions - Get-SmbShareAccess…

Basic CSS: Add Different Padding to Each Side of an Element

<style>.injected-text {margin-bottom: -25px;text-align: center;}.box {border-style: solid;border-color: black;border-width: 5px;text-align: center;}.yellow-box {background-color: yellow;padding: 10px;}.red-box {background-color: crimson;color: #fff;padding-top:…