Skip to content

Instantly share code, notes, and snippets.

@ckunte
Last active June 22, 2021 01:15
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ckunte/d57ed8ae8c13315416ac22b83ba1ac7c to your computer and use it in GitHub Desktop.
Save ckunte/d57ed8ae8c13315416ac22b83ba1ac7c to your computer and use it in GitHub Desktop.
Makefile for backups
# Makefile for backup routines
# 2021 ckunte
#
SOURCE=/home/Chyetanya.Kunte
# current (and archived) projects
PROJECTS=prj
# past projects
REFERENCES=ref
# Here's an example: make cprj IP="10.0.1.19"
# ref: https://stackoverflow.com/questions/15500204/
SRV=$(IP)
#
DEST=$(SRV):/Volumes/wrk
#
# Flags (CLI options)
# ref: https://stackoverflow.com/q/9177135
FLAGS=-auz --omit-dir-times --chmod=Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r -p --exclude-from=./exclude.txt --delete --delete-excluded --progress
# switch (safe): -vrldcmz
# For tunnelling with corkscrew
#PORT=-e 'ssh -D 443 -p 22'
# For direct access
PORT=-e 'ssh -p 22'
help: ## Show this help
@echo 'Makefile for backing-up projects and references'
@echo 'Usage: make <option> IP="<ip_address>"'
@echo 'options:'
@egrep -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-5s\033[0m %s\n", $$1, $$2}'
aph: cpf cdef csel ## all of phases to-date
cpf: ## post-DEFINE phase
@echo 'Backing-up post-FEED studies...'
@rsync $(FLAGS) $(SOURCE)/$(PROJECTS)/CRXPF/ $(PORT) $(DEST)/$(PROJECTS)/CRXPF/
cdef: ## DEFINE phase
@echo 'Backing-up FEED ...'
@rsync $(FLAGS) $(SOURCE)/$(PROJECTS)/CRXDEF/ $(PORT) $(DEST)/$(PROJECTS)/CRXDEF/
csel: ## SELECT phase
@echo 'Backing-up FEED ...'
@rsync $(FLAGS) $(SOURCE)/$(PROJECTS)/CRXSEL/ $(PORT) $(DEST)/$(PROJECTS)/CRXSEL/
proj: ## All projects
@echo 'Backing-up all projects...'
@rsync $(FLAGS) $(SOURCE)/$(PROJECTS)/ $(PORT) $(DEST)/$(PROJECTS)/
aref: ## All references
@echo 'Backing-up all references...'
@rsync $(FLAGS) $(SOURCE)/$(REFERENCES)/ $(PORT) $(DEST)/$(REFERENCES)/
.PHONY: cpf cdef help
@ckunte
Copy link
Author

ckunte commented Sep 26, 2017

Console view:

Makefile console view

@lil5
Copy link

lil5 commented Jan 21, 2018

Thanks for pushing this on the net.
It has helped me making my own.
I see you don't reference a licence, might I suggest <unlicense.org>

# License: unlicense <unlicense.org>

@ckunte
Copy link
Author

ckunte commented Mar 9, 2018

@lil5: I've taken your suggestion to add the unlicense to this file. Thank you for your feedback, and happy to note that it is useful to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment