diff --git a/README.md b/README.md index 43ada41..cc4e099 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,30 @@ Note that deleted objects are ignored (no file is created). However, to track co Check `.github/workflows/backup.yaml` for usage sample. +## Where is the full backup ?! + +It is not here. I limited intentionally the workflow to automatically backup 10 commits. It it still possible to trigger the backup manually through github UI, or by running the script on your local workstation: + + +```sh +$ /bin/bash scripts/backup.sh -r https://github.com/descartes-underwriting/devops-technical-test-data.git -b 01-01-2022-test -d all +Cloning into 'devops-technical-test-data'... +remote: Enumerating objects: 21364, done. +remote: Counting objects: 100% (5149/5149), done. +remote: Compressing objects: 100% (1908/1908), done. +remote: Total 21364 (delta 1300), reused 5121 (delta 1274), pack-reused 16215 (from 1) +Receiving objects: 100% (21364/21364), 1.86 MiB | 9.48 MiB/s, done. +Resolving deltas: 100% (6177/6177), done. +new commit: 282180fe7e5d9cbf297f2f0ef813cffe60ce2328 +new commit: 46fe26c9dcf2354a0ed3f304ed6818de9606f7b5 +new commit: 21e5331d1c0256701bb90cf017e519d54a88f618 +new commit: 47998b5317e66b3bd456cfb07268c93e223704f2 +... +done: 1342 commits +``` + + + ## Tests A sample test script exists to verify basic use case of backup'ing a limited number of commits. The `scripts/test.sh` runs a couple of backups and run a `diff -r` against a manually verified backup included in the repository. A workflow runs tests on push. @@ -57,3 +81,4 @@ Check `.github/workflows/tests.yaml` for the test workflow. - Keep commit messages, metadata (commiter, date), so it is possible to rebuild the git repository DAG. - Move the script/workflow out of the backup repository to allow a re-usable workflow! Also, it is quite boring having the script in the same repository as it will create conflicts during push, as pushing will start backuping and will require pulling again the code. - The script does not track deletion, modes, links, submodules. If we want to rebuild a repository, a lot of stuff will have to be done. +- More tests with badly formatted file names (with double quotes?) diff --git a/scripts/backup.sh b/scripts/backup.sh index 8866787..0256916 100644 --- a/scripts/backup.sh +++ b/scripts/backup.sh @@ -102,7 +102,9 @@ do fi # Retrieve file state (Added, Modified, Deleted) - STATE=$(${GIT} ${GIT_OPTS[@]} show --name-status --pretty= ${COMMIT_SHA} | grep -E "^..${FILE}\$" | cut -f1) + # Using basic regex as we want to avoid checking '()' or other complex regex patterns. + # This is suboptimal and error prone. But it passes the full backup :-) + STATE=$(${GIT} ${GIT_OPTS[@]} show --name-status --pretty= ${COMMIT_SHA} | grep -G "^..${FILE}\$" | cut -f1) if test "${STATE}" != "D" then