-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-auto-backup.cmd
More file actions
68 lines (60 loc) · 2.02 KB
/
git-auto-backup.cmd
File metadata and controls
68 lines (60 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
@echo off
title Backup - Git Repos
REM ---DESCRIPTION---
REM
REM Run this script as a daily windows job
REM It will rsync your local .git Repo folder to an external backup drive
REM and it also stores a Zip file with every modified uncommitted file
REM
REM Needs:
REM program cwRsync
REM program Perl
REM file '.rsync_filter_git' (specify git repo folders to backup here)
REM file 'sleep.pl'
REM
REM --- STEP 1: Backup Modified files in zip file ---
SET ZIP7=C:\PROGRA~1\7-Zip\7z.exe
REM (Copy and adapt below structure for all your repositories)
echo.
SET SRC=C:\Scripts
SET TRG=U:\600_Backup\Scripts
echo Backup Modified files of repo Scripts in zip file
mkdir %TRG% 2>nul
del %TRG%\ModifiedFiles.zip 2> nul
pushd %SRC%
echo [ git status -s ^| grep -E "^( A| M|\?\?)" ^| cut -d ' ' -f 3 ^| xargs %ZIP7% a -tzip %TRG%\ModifiedFiles.zip ]
git status -s | grep -E "^( A| M| D|\?\?)" && git status -s | grep -E "^( A| M|\?\?)" | cut -d ' ' -f 3 | xargs %ZIP7% a -tzip %TRG%\ModifiedFiles.zip 2> nul
popd
echo.
SET SRC=C:\workspace\projects\ICE\src
SET TRG=U:\600_Backup\projects\ICE
echo Backup Modified files of repo ICE in zip file
mkdir %TRG% 2>nul
del %TRG%\ModifiedFiles.zip 2> nul
pushd %SRC%
echo [ git status -s ^| grep -E "^( A| M|\?\?)" ^| cut -d ' ' -f 3 ^| xargs %ZIP7% a -tzip %TRG%\ModifiedFiles.zip ]
git status -s | grep -E "^( A| M| D|\?\?)" && git status -s | grep -E "^( A| M|\?\?)" | cut -d ' ' -f 3 | xargs %ZIP7% a -tzip %TRG%\ModifiedFiles.zip 2> nul
popd
REM --- STEP 2: Start Rsync process ---
set STARTTIME=%TIME%
echo.
echo Start Rsync ...
REM * Rsync
REM * Put the copy on a private or better public drive so that your team can easily access your code if necessary
rsync.exe --progress --stats --filter='. /cygdrive/c/Scripts/Git/.rsync_filter_git' -rltvz -k -L --del /cygdrive/c/workspace/ /cygdrive/u/600_Backup/
echo START %STARTTIME%
echo END %TIME%
if not errorlevel 0 goto Error
echo.
C:\Scripts\sleep.pl 5
goto End
:Error
echo.
echo ERROR DURING EXECUTION OF %0
echo.
echo
pause
:End
SET ZIP7=
SET SRC=
SET TRG=