Yesterday I talked about using robocopy (Windows command line tool), today I thought I would mention how I use 7zip's CLI to create an archive. This is useful to back-up many compressible files and run on a schedule in the background. Although I use Window's File History, it's nice to have another back-up with everything included.
The following batch file will get the date and time, format as YYYY_MM_DD__HH_MM_SS, to use later, then execute 7zip to compress the archive.
@echo off :: Back-up documents directory and compress to archive :: Get date set datetimef=%date:~-4%_%date:~3,2%_%date:~0,2%__%time:~0,2%_%time:~3,2%_%time:~6,2% :: Run the script from 7ZIP installation directory "C:\Program Files\7-Zip\7z.exe" a D:\Backups\Documents\%datetimef%.7z C:\Users\Karl\Documents\2023
I have used a to tell 7zip to create an archive. Using either Macrium or Windows Scheduler, I will set-up the script to run weekly.