initial commit
This commit is contained in:
		
							
								
								
									
										40
									
								
								.github/workflows/backup.yaml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								.github/workflows/backup.yaml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,40 @@ | ||||
| name: Run backup | ||||
|  | ||||
| on: | ||||
|   schedule: | ||||
|     - cron: '30 * * * 1-5' | ||||
|   push: | ||||
|     branches: | ||||
|       - main | ||||
|   workflow_dispatch: | ||||
|     inputs: | ||||
|       num: | ||||
|         description: 'Number of commit to backup (0: unlimited)' | ||||
|         required: true | ||||
|         default: '10' | ||||
|  | ||||
| jobs: | ||||
|   backup-and-push: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - name: Checkout repository | ||||
|         uses: actions/checkout@v4 | ||||
|  | ||||
|       - name: Set num default value | ||||
|         run: | | ||||
|           NUM=${{ github.event.inputs.num }} | ||||
|           echo "NUM=${NUM:-10}" >> $GITHUB_ENV | ||||
|  | ||||
|       - name: Run backup script | ||||
|         run: | | ||||
|           /bin/bash scripts/backup.sh -r https://github.com/descartes-underwriting/devops-technical-test-data.git -b 01-01-2022-test -n ${{ env.NUM }} | ||||
|           /bin/bash scripts/backup.sh -r https://github.com/descartes-underwriting/devops-technical-test-data.git -b main -d $(pwd)/data_main -n ${{ env.NUM }} | ||||
|          | ||||
|       - name: Commit and push changes | ||||
|         run: | | ||||
|           git config --local user.email "action@github.com" | ||||
|           git config --local user.name "GitHub Action" | ||||
|           git add data data_main | ||||
|           git commit -m "Auto-update from backup job" || exit 0 | ||||
|           git push | ||||
|  | ||||
							
								
								
									
										17
									
								
								.github/workflows/tests.yaml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								.github/workflows/tests.yaml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| name: Tests | ||||
|  | ||||
| on: | ||||
|   push: | ||||
|     branches: | ||||
|       - main | ||||
|  | ||||
| jobs: | ||||
|   tests: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - name: Checkout repository | ||||
|         uses: actions/checkout@v4 | ||||
|  | ||||
|       - name: Run tests | ||||
|         run: | | ||||
|           /bin/bash scripts/tests.sh | ||||
							
								
								
									
										49
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,49 @@ | ||||
| # backup.sh ~ descartes underwriting technical test for devops | ||||
|  | ||||
| The script takes as input a repository url, a branch, a destination directory and optionally a number of commit to backup, verbose mode, debug mode. | ||||
|  | ||||
| It checkouts a git repository, list all commits in a given branch (from oldest to most recent), and for each commit sha checks if it was already backuped (check for ${DATA_DIR}/<commit sha> directory), and if not, checks out all files mentionned in commit and dump their state at given commit into the per commit given directory. | ||||
|  | ||||
| The included workflow that actually performs the backup can be manually run through github UI. | ||||
|  | ||||
| ## Usage | ||||
|  | ||||
| ```sh | ||||
| $ /bin/bash scripts/backup.sh -r <repository> -b <branch> -d </path/to/data> [-n <commit limit>] [-v] [-x] | ||||
| ``` | ||||
|  | ||||
| Ex: | ||||
|  | ||||
| ```sh | ||||
| $ /bin/bash scripts/backup.sh -r https://github.com/descartes-underwriting/devops-technical-test-data.git -b 01-01-2022-test -d $(pwd)/data -n 5 | ||||
| Cloning into 'devops-technical-test-data'... | ||||
| remote: Enumerating objects: 21265, done. | ||||
| ... | ||||
| new commit: 282180fe7e5d9cbf297f2f0ef813cffe60ce2328 | ||||
| new commit: 46fe26c9dcf2354a0ed3f304ed6818de9606f7b5 | ||||
| new commit: 21e5331d1c0256701bb90cf017e519d54a88f618 | ||||
| new commit: 47998b5317e66b3bd456cfb07268c93e223704f2 | ||||
| new commit: 7c5aebc1feeef4eaf19083019547457b8cf3fc3d | ||||
| done: 5 | ||||
|  | ||||
| $ ls -l data/ | ||||
| total 0 | ||||
| drwxr-xr-x 1 patrick chicac  8 Jan  1 09:28 21e5331d1c0256701bb90cf017e519d54a88f618 | ||||
| drwxr-xr-x 1 patrick chicac 18 Jan  1 09:28 282180fe7e5d9cbf297f2f0ef813cffe60ce2328 | ||||
| drwxr-xr-x 1 patrick chicac 14 Jan  1 09:28 46fe26c9dcf2354a0ed3f304ed6818de9606f7b5 | ||||
| drwxr-xr-x 1 patrick chicac 14 Jan  1 09:28 47998b5317e66b3bd456cfb07268c93e223704f2 | ||||
| drwxr-xr-x 1 patrick chicac 14 Jan  1 09:28 7c5aebc1feeef4eaf19083019547457b8cf3fc3d | ||||
|  | ||||
| $ | ||||
| ``` | ||||
|  | ||||
| Check `.github/workflows/backup.yaml` for usage sample. | ||||
|  | ||||
| ## 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. | ||||
|  | ||||
| ## Not covered / Improvements ideas | ||||
|  | ||||
| - Deleted files in commits; The backup.sh script does not cover deleted files; | ||||
| - Keep track of latest commit backuped to allow iterative backups. As for now, the script checks all commits (which is not really efficient); However, if latest commit backup is tracked and this commit to be overwritten by a force push, it will be eventually required to re-do the whole backup. | ||||
							
								
								
									
										109
									
								
								scripts/backup.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										109
									
								
								scripts/backup.sh
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,109 @@ | ||||
| #!/bin/sh | ||||
|  | ||||
| set -e | ||||
|  | ||||
| REPOSITORY=https://github.com/descartes-underwriting/devops-technical-test-data.git | ||||
| BRANCH=main | ||||
| DATA_DIR=$(pwd)/data | ||||
| MAX_NUM=0 | ||||
| VERBOSE=0 | ||||
|  | ||||
| while getopts ":r:b:d:vxn:" opt | ||||
| do | ||||
|     case ${opt} in | ||||
|         r) | ||||
|             REPOSITORY=${OPTARG} | ||||
|             ;; | ||||
|         b) | ||||
|             BRANCH=${OPTARG} | ||||
|             ;; | ||||
|         d) | ||||
|             DATA_DIR=${OPTARG} | ||||
|             ;; | ||||
|         n) | ||||
|             MAX_NUM=${OPTARG} | ||||
|             ;; | ||||
|         v) | ||||
|             VERBOSE=1 | ||||
|             ;; | ||||
|         x) | ||||
|             set -x | ||||
|             ;; | ||||
|         ?) | ||||
|             echo "Invalid option -${OPTARG}" | ||||
|             exit 1 | ||||
|             ;; | ||||
|     esac | ||||
| done | ||||
|  | ||||
| IFS=" | ||||
| " | ||||
|  | ||||
| GIT=git | ||||
| GIT_OPTS=(-c core.quotepath=false) | ||||
|  | ||||
| if test ! -d ${DATA_DIR} | ||||
| then | ||||
|     mkdir -p ${DATA_DIR} | ||||
| fi | ||||
|  | ||||
| TMPDIR=$(mktemp -d) | ||||
| cd ${TMPDIR} | ||||
|  | ||||
| git clone ${REPOSITORY} && cd ./* | ||||
|  | ||||
| # List all commit sha, from older to newer;  | ||||
| COMMIT_SHAS=$($GIT ${GIT_OPTS[@]} log --reverse --pretty=format:"%H" remotes/origin/${BRANCH}) | ||||
|  | ||||
| NUM_ADDED=0 | ||||
|  | ||||
| for COMMIT_SHA in ${COMMIT_SHAS} | ||||
| do | ||||
|     if test -d ${DATA_DIR}/${COMMIT_SHA} | ||||
|     then | ||||
|         # commit already backup; skipping | ||||
|         continue | ||||
|     fi | ||||
|  | ||||
|     echo "new commit: ${COMMIT_SHA}" | ||||
|  | ||||
|     # There are malformed files names that are creating complex filenames to parse. | ||||
|     # Those malformed filenames are double quotes, so to remove quotes, -c core.quotepath=false | ||||
|     # and -z are used. sed 's/\x0//g' is removing the null byte | ||||
|     FILES=$($GIT ${GIT_OPTS[@]} show --pretty= --name-only -z ${COMMIT_SHA} | sed 's/\x0//g')  | ||||
|  | ||||
|     if test -z ${FILES} | ||||
|     then | ||||
|         # merge commit, etc. There is no file here. | ||||
|         echo "No file was found in commit ${COMMIT_SHA}; skipping" | ||||
|         continue | ||||
|     fi | ||||
|  | ||||
|     TARGET_BACKUP_SHA=${DATA_DIR}/${COMMIT_SHA} | ||||
|     mkdir -p ${TARGET_BACKUP_SHA} | ||||
|  | ||||
|     for FILE in ${FILES} | ||||
|     do | ||||
|         TARGET_DIR=$(dirname ${FILE}) | ||||
|         mkdir -p ${TARGET_BACKUP_SHA}/${TARGET_DIR} | ||||
|  | ||||
|         if test ${VERBOSE} -eq 1 | ||||
|         then | ||||
|             echo "Writing ${TARGET_BACKUP_SHA}/${FILE}" | ||||
|         fi | ||||
|  | ||||
|         # ${FILE} contains path/to/file | ||||
|         $GIT ${GIT_OPTS[@]} show ${COMMIT_SHA}:${FILE} > ${TARGET_BACKUP_SHA}/${FILE} | ||||
|     done | ||||
|  | ||||
|     NUM_ADDED=$((NUM_ADDED + 1)) | ||||
|  | ||||
|     if test ${NUM_ADDED} -eq ${MAX_NUM} | ||||
|     then | ||||
|         echo "Max commit to backup reached; stopping." | ||||
|         break | ||||
|     fi | ||||
| done | ||||
|  | ||||
| echo "done: ${NUM_ADDED}" | ||||
|  | ||||
							
								
								
									
										26
									
								
								scripts/tests.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								scripts/tests.sh
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,26 @@ | ||||
| #!/bin/sh | ||||
|  | ||||
| run_test() { | ||||
|     echo "Running backup on branch main; dest $1; num: $2..." | ||||
|     /bin/bash scripts/backup.sh -b main -d $1 -n $2 | ||||
|     echo | ||||
|     diff -r $1 tests/tests_cases/$2 | ||||
|     if test $? -ne 0 | ||||
|     then | ||||
|         echo "Test fail" | ||||
|         exit 1 | ||||
|     fi | ||||
|     echo "... done" | ||||
|     echo | ||||
| } | ||||
|  | ||||
| ROOTDIR=$(git rev-parse --show-toplevel) | ||||
| TMPDIR=$(mktemp -d) | ||||
|  | ||||
| cd ${ROOTDIR} | ||||
|  | ||||
| run_test ${TMPDIR}/1 1 | ||||
| run_test ${TMPDIR}/2 2 | ||||
| run_test ${TMPDIR}/10 10 | ||||
|  | ||||
| echo "All tests were OK" | ||||
| @@ -0,0 +1,78 @@ | ||||
| # Descartes Underwriting | ||||
|  | ||||
| ## Context | ||||
|  | ||||
| We wish to create a backup tool that will save only the last modified files of a storage unit. | ||||
|  | ||||
| In our example, the storage unit is **not a bucket**. | ||||
|  | ||||
| The storage unit is a git repository called `devops-technical-test-data`. | ||||
|  | ||||
| The repository `devops-technical-test-data` is not frozen and will have new commits. | ||||
|  | ||||
| Commits will be added to the `datestamp-test` branch on the `devops-technical-test-data` repository. | ||||
|  | ||||
| ## Task | ||||
|  | ||||
| Develop a backup tool to save the modified files at each commit. | ||||
|  | ||||
| ### Submission | ||||
|  | ||||
| Script and data should be saved on a private `descartes-backup-project` repository on your github account. | ||||
|  | ||||
| Access should be granted to all members of the `descartes-underwriting` group: | ||||
|  | ||||
| <https://github.com/orgs/descartes-underwriting/people> | ||||
|  | ||||
| ### Script | ||||
|  | ||||
| Create a script to automate the backup process using open source software. | ||||
|  | ||||
| The script should track the branch `datestamp-test` of the repository. | ||||
|  | ||||
| The execution of the script should be carried with a github-action / gitlab-pipeline or any other git automated workflow. | ||||
|  | ||||
| ### Data | ||||
|  | ||||
| The backup should store files in separate folders. | ||||
|  | ||||
| The backup file structure should be based on the sha1 of the `devops-technical-test-data`. | ||||
|  | ||||
| ## File structure example | ||||
|  | ||||
| For the following commits on the `devops-technical-test-data`: | ||||
|  | ||||
| | SHA | OPERATION | | ||||
| |-----|-----------| | ||||
| | Commit_N | create readme.md | | ||||
| | Commit_N+1 | create doc.txt | | ||||
| | Commit_N+2 | create data/test/test.txt | | ||||
| | Commit_N+3 | append text to ./doc.txt | | ||||
| | Commit_N+4 | create test/project/project1.txt | | ||||
|  | ||||
| The `candidate_backup_repository` should have | ||||
|  | ||||
| ```bash | ||||
| $ tree . | ||||
| . | ||||
| ├── .gitworkflow | ||||
| │   └── workflows | ||||
| │       └── my-lovely-workflow.yml | ||||
| ├── data | ||||
| │   ├── N | ||||
| │   │   └── readme.md | ||||
| │   ├── N+1 | ||||
| │   │   └── doc.txt | ||||
| │   ├── N+2 | ||||
| │   │   └── data | ||||
| │   │       └── test | ||||
| │   │           └── test.txt | ||||
| │   ├── N+3 | ||||
| │   │   └── doc.txt | ||||
| │   └── N+4 | ||||
| │       └── test | ||||
| │           └── project | ||||
| │               └── project1.txt | ||||
| └── script | ||||
|     └── my-beautiful-script.best-language | ||||
| ``` | ||||
| @@ -0,0 +1,84 @@ | ||||
| # Descartes Underwriting | ||||
|  | ||||
| ## Context | ||||
|  | ||||
| We wish to create a backup tool that will save only the last modified files of a storage unit. | ||||
|  | ||||
| In our example, the storage unit is **not a bucket**. | ||||
|  | ||||
| The storage unit is the `DD-MM-YYYY-test` branch of the current `descartes-underwriting/devops-technical-test-data` git repository. | ||||
|  | ||||
| ## Property | ||||
|  | ||||
| The `descartes-underwriting/devops-technical-test-data` repository is not frozen and will have new commits. | ||||
|  | ||||
| Commits will be added to the `DD-MM-YYYY-test` branch multiple times every day. | ||||
|  | ||||
| The `DD-MM-YYYY-test` branch name will be adapted using standard datetime convention eg: `01-01-2022-test` for the 1st of January 2022. | ||||
|  | ||||
| ## Task | ||||
|  | ||||
| Develop a backup tool to save the modified files at each commit. | ||||
|  | ||||
| ### Submission | ||||
|  | ||||
| Script and data should be saved on a private `candidate/descartes-backup-project` repository on your github account. | ||||
|  | ||||
| Access should be granted to all members of the `descartes-underwriting` group: | ||||
|  | ||||
| <https://github.com/orgs/descartes-underwriting/people> | ||||
|  | ||||
| ### Script | ||||
|  | ||||
| Create a script to automate the backup process using open source software. | ||||
|  | ||||
| The script should track the changes fo the branch `DD-MM-YYYY-test` of the `descartes-underwriting/devops-technical-test-data` repository. | ||||
|  | ||||
| The execution of the script should be carried out with a github-action / gitlab-pipeline or any other tool automating git workflow on your git project. | ||||
|  | ||||
| It is highly recommended to use a scheduling tool to execute the back up process. | ||||
|  | ||||
| ### Data | ||||
|  | ||||
| The backup should store files in separate folders. | ||||
|  | ||||
| The backup file structure should be based on the sha1 of the `descartes-underwriting/devops-technical-test-data`. | ||||
|  | ||||
| ## File structure example | ||||
|  | ||||
| For the following commits on the `descartes-underwriting/devops-technical-test-data`: | ||||
|  | ||||
| | SHA | OPERATION | | ||||
| |-----|-----------| | ||||
| | Commit_N | create readme.md | | ||||
| | Commit_N+1 | create doc.txt | | ||||
| | Commit_N+2 | create data/test/test.txt | | ||||
| | Commit_N+3 | append text to ./doc.txt | | ||||
| | Commit_N+4 | create test/project/project1.txt | | ||||
|  | ||||
| The `candidate/descartes-backup-project` repository should have | ||||
|  | ||||
| ```bash | ||||
| $ tree . | ||||
| . | ||||
| ├── .gitworkflow | ||||
| │   └── workflows | ||||
| │       └── my-lovely-workflow.yml | ||||
| ├── data | ||||
| │   ├── N | ||||
| │   │   └── readme.md | ||||
| │   ├── N+1 | ||||
| │   │   └── doc.txt | ||||
| │   ├── N+2 | ||||
| │   │   └── data | ||||
| │   │       └── test | ||||
| │   │           └── test.txt | ||||
| │   ├── N+3 | ||||
| │   │   └── doc.txt | ||||
| │   └── N+4 | ||||
| │       └── test | ||||
| │           └── project | ||||
| │               └── project1.txt | ||||
| └── script | ||||
|     └── my-beautiful-script.best-language | ||||
| ``` | ||||
| @@ -0,0 +1 @@ | ||||
| This is a test file | ||||
| @@ -0,0 +1,78 @@ | ||||
| # Descartes Underwriting | ||||
|  | ||||
| ## Context | ||||
|  | ||||
| We wish to create a backup tool that will save only the last modified files of a storage unit. | ||||
|  | ||||
| In our example, the storage unit is **not a bucket**. | ||||
|  | ||||
| The storage unit is a git repository called `devops-technical-test-data`. | ||||
|  | ||||
| The repository `devops-technical-test-data` is not frozen and will have new commits. | ||||
|  | ||||
| Commits will be added to the `datestamp-test` branch on the `devops-technical-test-data` repository. | ||||
|  | ||||
| ## Task | ||||
|  | ||||
| Develop a backup tool to save the modified files at each commit. | ||||
|  | ||||
| ### Submission | ||||
|  | ||||
| Script and data should be saved on a private `descartes-backup-project` repository on your github account. | ||||
|  | ||||
| Access should be granted to all members of the `descartes-underwriting` group: | ||||
|  | ||||
| <https://github.com/orgs/descartes-underwriting/people> | ||||
|  | ||||
| ### Script | ||||
|  | ||||
| Create a script to automate the backup process using open source software. | ||||
|  | ||||
| The script should track the branch `datestamp-test` of the repository. | ||||
|  | ||||
| The execution of the script should be carried with a github-action / gitlab-pipeline or any other git automated workflow. | ||||
|  | ||||
| ### Data | ||||
|  | ||||
| The backup should store files in separate folders. | ||||
|  | ||||
| The backup file structure should be based on the sha1 of the `devops-technical-test-data`. | ||||
|  | ||||
| ## File structure example | ||||
|  | ||||
| For the following commits on the `devops-technical-test-data`: | ||||
|  | ||||
| | SHA | OPERATION | | ||||
| |-----|-----------| | ||||
| | Commit_N | create readme.md | | ||||
| | Commit_N+1 | create doc.txt | | ||||
| | Commit_N+2 | create data/test/test.txt | | ||||
| | Commit_N+3 | append text to ./doc.txt | | ||||
| | Commit_N+4 | create test/project/project1.txt | | ||||
|  | ||||
| The `candidate_backup_repository` should have | ||||
|  | ||||
| ```bash | ||||
| $ tree . | ||||
| . | ||||
| ├── .gitworkflow | ||||
| │   └── workflows | ||||
| │       └── my-lovely-workflow.yml | ||||
| ├── data | ||||
| │   ├── N | ||||
| │   │   └── readme.md | ||||
| │   ├── N+1 | ||||
| │   │   └── doc.txt | ||||
| │   ├── N+2 | ||||
| │   │   └── data | ||||
| │   │       └── test | ||||
| │   │           └── test.txt | ||||
| │   ├── N+3 | ||||
| │   │   └── doc.txt | ||||
| │   └── N+4 | ||||
| │       └── test | ||||
| │           └── project | ||||
| │               └── project1.txt | ||||
| └── script | ||||
|     └── my-beautiful-script.best-language | ||||
| ``` | ||||
| @@ -0,0 +1 @@ | ||||
| This is a doc | ||||
| @@ -0,0 +1,2 @@ | ||||
| This is a doc | ||||
| Hello, world ! | ||||
| @@ -0,0 +1,89 @@ | ||||
| # Descartes Underwriting | ||||
|  | ||||
| ## Context | ||||
|  | ||||
| We wish to create a backup tool that will save only the last modified files of a storage unit. | ||||
|  | ||||
| In our example, the storage unit is **not a bucket**. | ||||
|  | ||||
| The storage unit is the `DD-MM-YYYY-test` branch of the current `descartes-underwriting/devops-technical-test-data` git repository. | ||||
|  | ||||
| ## Property | ||||
|  | ||||
| The `descartes-underwriting/devops-technical-test-data` repository is not frozen and will have new commits. | ||||
|  | ||||
| Commits will be added to the `DD-MM-YYYY-test` branch multiple times every day. | ||||
|  | ||||
| The `DD-MM-YYYY-test` branch name will be adapted using standard datetime convention eg: `01-01-2022-test` for the 1st of January 2022. | ||||
|  | ||||
| ## Task | ||||
|  | ||||
| Develop a backup tool to save the modified files at each commit. | ||||
|  | ||||
| ### Submission | ||||
|  | ||||
| Script and data should be saved on a private `candidate/descartes-backup-project` repository on your github account. | ||||
|  | ||||
| Access should be granted to all members of the `descartes-underwriting` group: | ||||
|  | ||||
| <https://github.com/orgs/descartes-underwriting/people> | ||||
|  | ||||
| Especially: | ||||
|  | ||||
| * <https://github.com/alexandreCameron> | ||||
| * <https://github.com/Mareak> | ||||
|  | ||||
| ### Script | ||||
|  | ||||
| Create a script to automate the backup process using open source software. | ||||
|  | ||||
| The script should track the changes fo the branch `DD-MM-YYYY-test` of the `descartes-underwriting/devops-technical-test-data` repository. | ||||
|  | ||||
| The execution of the script should be carried out with a github-action / gitlab-pipeline or any other tool automating git workflow on your git project. | ||||
|  | ||||
| It is highly recommended to use a scheduling tool to execute the back up process. | ||||
|  | ||||
| ### Data | ||||
|  | ||||
| The backup should store files in separate folders. | ||||
|  | ||||
| The backup file structure should be based on the sha1 of the `descartes-underwriting/devops-technical-test-data`. | ||||
|  | ||||
| ## File structure example | ||||
|  | ||||
| For the following commits on the `descartes-underwriting/devops-technical-test-data`: | ||||
|  | ||||
| | SHA | OPERATION | | ||||
| |-----|-----------| | ||||
| | Commit_N | create readme.md | | ||||
| | Commit_N+1 | create doc.txt | | ||||
| | Commit_N+2 | create data/test/test.txt | | ||||
| | Commit_N+3 | append text to ./doc.txt | | ||||
| | Commit_N+4 | create test/project/project1.txt | | ||||
|  | ||||
| The `candidate/descartes-backup-project` repository should have | ||||
|  | ||||
| ```bash | ||||
| $ tree . | ||||
| . | ||||
| ├── .gitworkflow | ||||
| │   └── workflows | ||||
| │       └── my-lovely-workflow.yml | ||||
| ├── data | ||||
| │   ├── N | ||||
| │   │   └── readme.md | ||||
| │   ├── N+1 | ||||
| │   │   └── doc.txt | ||||
| │   ├── N+2 | ||||
| │   │   └── data | ||||
| │   │       └── test | ||||
| │   │           └── test.txt | ||||
| │   ├── N+3 | ||||
| │   │   └── doc.txt | ||||
| │   └── N+4 | ||||
| │       └── test | ||||
| │           └── project | ||||
| │               └── project1.txt | ||||
| └── script | ||||
|     └── my-beautiful-script.best-language | ||||
| ``` | ||||
| @@ -0,0 +1,91 @@ | ||||
| # Descartes Underwriting | ||||
|  | ||||
| ## Context | ||||
|  | ||||
| We wish to create a backup tool that will save only the last modified files of a storage unit. | ||||
|  | ||||
| In our example, the storage unit is **not a bucket**. | ||||
|  | ||||
| The storage unit is the `DD-MM-YYYY-test` branch of the current `descartes-underwriting/devops-technical-test-data` git repository. | ||||
|  | ||||
| ## Property | ||||
|  | ||||
| The `descartes-underwriting/devops-technical-test-data` repository is not frozen and will have new commits. | ||||
|  | ||||
| Commits will be added to the `DD-MM-YYYY-test` branch multiple times every day. | ||||
|  | ||||
| The `DD-MM-YYYY-test` branch name will be adapted using standard datetime convention eg: `01-01-2022-test` for the 1st of January 2022. | ||||
|  | ||||
| ## Task | ||||
|  | ||||
| Develop a backup tool to save the modified files at each commit. | ||||
|  | ||||
| ### Submission | ||||
|  | ||||
| Script and data should be saved on a private `candidate/descartes-backup-project` repository on your github account. | ||||
|  | ||||
| Access should be granted to all members of the `descartes-underwriting` group: | ||||
|  | ||||
| <https://github.com/orgs/descartes-underwriting/people> | ||||
|  | ||||
| Especially: | ||||
|  | ||||
| * <https://github.com/alexandreCameron> | ||||
| * <https://github.com/Mareak> | ||||
|  | ||||
| ### Script | ||||
|  | ||||
| Create a script to automate the backup process using open source software. | ||||
|  | ||||
| The script should track the changes fo the branch `DD-MM-YYYY-test` of the `descartes-underwriting/devops-technical-test-data` repository. | ||||
|  | ||||
| The execution of the script should be carried out with a github-action / gitlab-pipeline or any other tool automating git workflow on your git project. | ||||
|  | ||||
| It is highly recommended to use a scheduling tool to execute the back up process. | ||||
|  | ||||
| ### Data | ||||
|  | ||||
| The backup should store files in separate folders. | ||||
|  | ||||
| The backup file structure should be based on the sha1 of the `descartes-underwriting/devops-technical-test-data`. | ||||
|  | ||||
| Starting from the initial commit [282180fe7e5d9cbf297f2f0ef813cffe60ce2328](https://github.com/descartes-underwriting/devops-technical-test-data/commit/282180fe7e5d9cbf297f2f0ef813cffe60ce2328), all the history should be backup. | ||||
|  | ||||
| ## File structure example | ||||
|  | ||||
| For the following commits on the `descartes-underwriting/devops-technical-test-data`: | ||||
|  | ||||
| | SHA | OPERATION | | ||||
| |-----|-----------| | ||||
| | Commit_N | create readme.md | | ||||
| | Commit_N+1 | create doc.txt | | ||||
| | Commit_N+2 | create data/test/test.txt | | ||||
| | Commit_N+3 | append text to ./doc.txt | | ||||
| | Commit_N+4 | create test/project/project1.txt | | ||||
|  | ||||
| The `candidate/descartes-backup-project` repository should have | ||||
|  | ||||
| ```bash | ||||
| $ tree . | ||||
| . | ||||
| ├── .gitworkflow | ||||
| │   └── workflows | ||||
| │       └── my-lovely-workflow.yml | ||||
| ├── data | ||||
| │   ├── N | ||||
| │   │   └── readme.md | ||||
| │   ├── N+1 | ||||
| │   │   └── doc.txt | ||||
| │   ├── N+2 | ||||
| │   │   └── data | ||||
| │   │       └── test | ||||
| │   │           └── test.txt | ||||
| │   ├── N+3 | ||||
| │   │   └── doc.txt | ||||
| │   └── N+4 | ||||
| │       └── test | ||||
| │           └── project | ||||
| │               └── project1.txt | ||||
| └── script | ||||
|     └── my-beautiful-script.best-language | ||||
| ``` | ||||
| @@ -0,0 +1,100 @@ | ||||
| # Descartes Underwriting | ||||
|  | ||||
| ## Context | ||||
|  | ||||
| We wish to create a backup tool that will save only the last modified files of a storage unit. | ||||
|  | ||||
| In our example, the storage unit is **not a bucket**. | ||||
|  | ||||
| The storage unit is the `DD-MM-YYYY-test` branch of the current `descartes-underwriting/devops-technical-test-data` git repository. | ||||
|  | ||||
| ## Property | ||||
|  | ||||
| The `descartes-underwriting/devops-technical-test-data` repository is not frozen and will have new commits. | ||||
|  | ||||
| Commits will be added to the `DD-MM-YYYY-test` branch multiple times every day. | ||||
|  | ||||
| The `DD-MM-YYYY-test` branch name will be adapted using standard datetime convention eg: `01-01-2022-test` for the 1st of January 2022. | ||||
|  | ||||
| ## Task | ||||
|  | ||||
| Develop a backup tool to save the modified files at each commit. | ||||
|  | ||||
| ### Submission | ||||
|  | ||||
| If something is not clear, you can ask questions to the recruiter. | ||||
|  | ||||
| When submitting your project, your version should **not be draft** but complete and following best practices. | ||||
|  | ||||
| The solution should be saved on a **private** `descartes-devops` repository on your github account. | ||||
|  | ||||
| The solution should include: | ||||
|  | ||||
| - source code | ||||
| - test code | ||||
|  | ||||
| When the final version is ready: | ||||
|  | ||||
| 1. Send an email to the recruiter indicating that you finished the project and sharing the url of the project | ||||
| 2. Grant access to: | ||||
|  | ||||
| - <https://github.com/alexandreCameron> | ||||
| - <https://github.com/Mareak> | ||||
| - <https://github.com/jrdescartes> | ||||
|  | ||||
| ### Script | ||||
|  | ||||
| Create a script to automate the backup process using open source software. | ||||
|  | ||||
| The script should track the changes fo the branch `DD-MM-YYYY-test` of the `descartes-underwriting/devops-technical-test-data` repository. | ||||
|  | ||||
| The execution of the script should be carried out with a github-action / gitlab-pipeline or any other tool automating git workflow on your git project. | ||||
|  | ||||
| It is highly recommended to use a scheduling tool to execute the back up process. | ||||
|  | ||||
| ### Data | ||||
|  | ||||
| The backup should store files in separate folders. | ||||
|  | ||||
| The backup file structure should be based on the sha1 of the `descartes-underwriting/devops-technical-test-data`. | ||||
|  | ||||
| Starting from the initial commit [282180fe7e5d9cbf297f2f0ef813cffe60ce2328](https://github.com/descartes-underwriting/devops-technical-test-data/commit/282180fe7e5d9cbf297f2f0ef813cffe60ce2328), all the history should be backup. | ||||
|  | ||||
| ## File structure example | ||||
|  | ||||
| For the following commits on the `descartes-underwriting/devops-technical-test-data`: | ||||
|  | ||||
| | SHA | OPERATION | | ||||
| |-----|-----------| | ||||
| | Commit_N | create readme.md | | ||||
| | Commit_N+1 | create doc.txt | | ||||
| | Commit_N+2 | create data/test/test.txt | | ||||
| | Commit_N+3 | append text to ./doc.txt | | ||||
| | Commit_N+4 | create test/project/project1.txt | | ||||
|  | ||||
| The `candidate/descartes-backup-project` repository should have | ||||
|  | ||||
| ```bash | ||||
| $ tree . | ||||
| . | ||||
| ├── .gitworkflow | ||||
| │   └── workflows | ||||
| │       └── my-lovely-workflow.yml | ||||
| ├── data | ||||
| │   ├── N | ||||
| │   │   └── readme.md | ||||
| │   ├── N+1 | ||||
| │   │   └── doc.txt | ||||
| │   ├── N+2 | ||||
| │   │   └── data | ||||
| │   │       └── test | ||||
| │   │           └── test.txt | ||||
| │   ├── N+3 | ||||
| │   │   └── doc.txt | ||||
| │   └── N+4 | ||||
| │       └── test | ||||
| │           └── project | ||||
| │               └── project1.txt | ||||
| └── script | ||||
|     └── my-beautiful-script.best-language | ||||
| ``` | ||||
| @@ -0,0 +1 @@ | ||||
| This is project1 | ||||
| @@ -0,0 +1,92 @@ | ||||
| # Descartes Underwriting | ||||
|  | ||||
| ## Context | ||||
|  | ||||
| We wish to create a backup tool that will save only the last modified files of a storage unit. | ||||
|  | ||||
| In our example, the storage unit is **not a bucket**. | ||||
|  | ||||
| The storage unit is the `DD-MM-YYYY-test` branch of the current `descartes-underwriting/devops-technical-test-data` git repository. | ||||
|  | ||||
| ## Property | ||||
|  | ||||
| The `descartes-underwriting/devops-technical-test-data` repository is not frozen and will have new commits. | ||||
|  | ||||
| Commits will be added to the `DD-MM-YYYY-test` branch multiple times every day. | ||||
|  | ||||
| The `DD-MM-YYYY-test` branch name will be adapted using standard datetime convention eg: `01-01-2022-test` for the 1st of January 2022. | ||||
|  | ||||
| ## Task | ||||
|  | ||||
| Develop a backup tool to save the modified files at each commit. | ||||
|  | ||||
| ### Submission | ||||
|  | ||||
| Script and data should be saved on a private `candidate/descartes-backup-project` repository on your github account. | ||||
|  | ||||
| Access should be granted to all members of the `descartes-underwriting` group: | ||||
|  | ||||
| <https://github.com/orgs/descartes-underwriting/people> | ||||
|  | ||||
| Especially: | ||||
|  | ||||
| * <https://github.com/alexandreCameron> | ||||
| * <https://github.com/Mareak> | ||||
| * <https://github.com/jrdescartes> | ||||
|  | ||||
| ### Script | ||||
|  | ||||
| Create a script to automate the backup process using open source software. | ||||
|  | ||||
| The script should track the changes fo the branch `DD-MM-YYYY-test` of the `descartes-underwriting/devops-technical-test-data` repository. | ||||
|  | ||||
| The execution of the script should be carried out with a github-action / gitlab-pipeline or any other tool automating git workflow on your git project. | ||||
|  | ||||
| It is highly recommended to use a scheduling tool to execute the back up process. | ||||
|  | ||||
| ### Data | ||||
|  | ||||
| The backup should store files in separate folders. | ||||
|  | ||||
| The backup file structure should be based on the sha1 of the `descartes-underwriting/devops-technical-test-data`. | ||||
|  | ||||
| Starting from the initial commit [282180fe7e5d9cbf297f2f0ef813cffe60ce2328](https://github.com/descartes-underwriting/devops-technical-test-data/commit/282180fe7e5d9cbf297f2f0ef813cffe60ce2328), all the history should be backup. | ||||
|  | ||||
| ## File structure example | ||||
|  | ||||
| For the following commits on the `descartes-underwriting/devops-technical-test-data`: | ||||
|  | ||||
| | SHA | OPERATION | | ||||
| |-----|-----------| | ||||
| | Commit_N | create readme.md | | ||||
| | Commit_N+1 | create doc.txt | | ||||
| | Commit_N+2 | create data/test/test.txt | | ||||
| | Commit_N+3 | append text to ./doc.txt | | ||||
| | Commit_N+4 | create test/project/project1.txt | | ||||
|  | ||||
| The `candidate/descartes-backup-project` repository should have | ||||
|  | ||||
| ```bash | ||||
| $ tree . | ||||
| . | ||||
| ├── .gitworkflow | ||||
| │   └── workflows | ||||
| │       └── my-lovely-workflow.yml | ||||
| ├── data | ||||
| │   ├── N | ||||
| │   │   └── readme.md | ||||
| │   ├── N+1 | ||||
| │   │   └── doc.txt | ||||
| │   ├── N+2 | ||||
| │   │   └── data | ||||
| │   │       └── test | ||||
| │   │           └── test.txt | ||||
| │   ├── N+3 | ||||
| │   │   └── doc.txt | ||||
| │   └── N+4 | ||||
| │       └── test | ||||
| │           └── project | ||||
| │               └── project1.txt | ||||
| └── script | ||||
|     └── my-beautiful-script.best-language | ||||
| ``` | ||||
| @@ -0,0 +1,78 @@ | ||||
| # Descartes Underwriting | ||||
|  | ||||
| ## Context | ||||
|  | ||||
| We wish to create a backup tool that will save only the last modified files of a storage unit. | ||||
|  | ||||
| In our example, the storage unit is **not a bucket**. | ||||
|  | ||||
| The storage unit is a git repository called `devops-technical-test-data`. | ||||
|  | ||||
| The repository `devops-technical-test-data` is not frozen and will have new commits. | ||||
|  | ||||
| Commits will be added to the `datestamp-test` branch on the `devops-technical-test-data` repository. | ||||
|  | ||||
| ## Task | ||||
|  | ||||
| Develop a backup tool to save the modified files at each commit. | ||||
|  | ||||
| ### Submission | ||||
|  | ||||
| Script and data should be saved on a private `descartes-backup-project` repository on your github account. | ||||
|  | ||||
| Access should be granted to all members of the `descartes-underwriting` group: | ||||
|  | ||||
| <https://github.com/orgs/descartes-underwriting/people> | ||||
|  | ||||
| ### Script | ||||
|  | ||||
| Create a script to automate the backup process using open source software. | ||||
|  | ||||
| The script should track the branch `datestamp-test` of the repository. | ||||
|  | ||||
| The execution of the script should be carried with a github-action / gitlab-pipeline or any other git automated workflow. | ||||
|  | ||||
| ### Data | ||||
|  | ||||
| The backup should store files in separate folders. | ||||
|  | ||||
| The backup file structure should be based on the sha1 of the `devops-technical-test-data`. | ||||
|  | ||||
| ## File structure example | ||||
|  | ||||
| For the following commits on the `devops-technical-test-data`: | ||||
|  | ||||
| | SHA | OPERATION | | ||||
| |-----|-----------| | ||||
| | Commit_N | create readme.md | | ||||
| | Commit_N+1 | create doc.txt | | ||||
| | Commit_N+2 | create data/test/test.txt | | ||||
| | Commit_N+3 | append text to ./doc.txt | | ||||
| | Commit_N+4 | create test/project/project1.txt | | ||||
|  | ||||
| The `candidate_backup_repository` should have | ||||
|  | ||||
| ```bash | ||||
| $ tree . | ||||
| . | ||||
| ├── .gitworkflow | ||||
| │   └── workflows | ||||
| │       └── my-lovely-workflow.yml | ||||
| ├── data | ||||
| │   ├── N | ||||
| │   │   └── readme.md | ||||
| │   ├── N+1 | ||||
| │   │   └── doc.txt | ||||
| │   ├── N+2 | ||||
| │   │   └── data | ||||
| │   │       └── test | ||||
| │   │           └── test.txt | ||||
| │   ├── N+3 | ||||
| │   │   └── doc.txt | ||||
| │   └── N+4 | ||||
| │       └── test | ||||
| │           └── project | ||||
| │               └── project1.txt | ||||
| └── script | ||||
|     └── my-beautiful-script.best-language | ||||
| ``` | ||||
| @@ -0,0 +1 @@ | ||||
| This is a doc | ||||
		Reference in New Issue
	
	Block a user