Skip to content

Instantly share code, notes, and snippets.

@kampee
Created September 12, 2021 03:36
Show Gist options
  • Save kampee/1c117093f1555ec871aef2eefc565994 to your computer and use it in GitHub Desktop.
Save kampee/1c117093f1555ec871aef2eefc565994 to your computer and use it in GitHub Desktop.
Simple 7-Zip based backup script
@echo off
REM # Send To Backup Script
REM # Author - Matt Little (http://matthewjlittle.com)
REM # Adam Caudill (http://adamcaudill.com)
REM #
REM # To install:
REM #
REM # (windows 7):
REM # Goto Start->Run. Type in shell:sendto
REM # Save as Backup.bat
REM #
REM # To use:
REM # right click on the folder you want to backup and click on the batch file
REM # in the sendto menu.
REM #
REM # Example:
REM #
REM # If you are in this folder and run the script on Production folder a
REM # backup of the folder is placed in
REM # X:\App\Prod\Backups\Prod.YYYY.MM.DD.HHMI.zip
REM #
set year=%date:~-4,4%
set month=%date:~-10,2%
set day=%date:~-7,2%
set hour=%time:~-11,2%
set hour=%hour: =0%
set min=%time:~-8,2%
set zipfilename=%~n1.%year%.%month%.%day%.%hour%%min%.zip
set destination=%~dp1
set source="%~1\*"
set dest="%destination%Backups\%zipfilename%"
set AppExePath="%ProgramFiles(x86)%\7-Zip\7z.exe"
if not exist %AppExePath% set AppExePath="%ProgramFiles%\7-Zip\7z.exe"
if not exist %AppExePath% goto notInstalled
echo Backing up %source% to %dest%
%AppExePath% a -rtzip %dest% %source%
echo %source% backed up to %dest% is complete!
goto end
:notInstalled
echo Can not find 7-Zip, please install it from:
echo http://7-zip.org/
:end
PAUSE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment