Skip to content

Instantly share code, notes, and snippets.

@Zuhayer
Created November 12, 2016 05:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zuhayer/addc333384d7c9415b2c5b3454181542 to your computer and use it in GitHub Desktop.
Save Zuhayer/addc333384d7c9415b2c5b3454181542 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