Instantly share code, notes, and snippets.

@ckunte /Makefile
Last active Mar 11, 2018

Embed
What would you like to do?
My Makefile for backups
# Makefile for backup and restore routines
# 2017 ckunte
# License: unlicense <unlicense.org>
SRCE=/Volumes/643
CPRJ=cproj
PPRJ=pproj
CREF=cref
PREF=pref
DEST=/Volumes/CK240
SHELL=/bin/zsh
default:
@echo "Makefile for backup and restore routines"
@echo
@echo 'Usage:'
@echo
@echo ' make backup backup all mail projects references'
@echo ' make restore restore all mail projects references'
@echo ' make mail backup all mail'
@echo ' make proj backup all projects'
@echo ' make curr backup only current projects'
@echo ' make past backup only past projects'
@echo ' make ref backup all references'
@echo ' make cref backup only current references'
@echo ' make pref backup only past references'
backup: mail proj ref
mail:
@echo "Backing up all email .."
@rsync -auv --delete ${SRCE}/mail/ ${DEST}/mail
proj: curr past
ref: cref pref
curr:
@echo "Backing up current projects .."
@rsync -auv --delete ${SRCE}/${CPRJ}/ ${DEST}/${CPRJ}
past:
@echo "Backing up past projects .."
@rsync -auv --delete ${SRCE}/${PPRJ}/ ${DEST}/${PPRJ}
cref:
@echo "Backing up current references .."
@rsync -auv --delete ${SRCE}/${CREF}/ ${DEST}/${CREF}
pref:
@echo "Backing up past references .."
@rsync -auv --delete ${SRCE}/${PREF}/ ${DEST}/${PREF}
restore:
@echo "Restoring mail .."
@rsync -auvmn ${DEST}/mail/ ${SRCE}/mail
@echo "Restoring projects .."
@rsync -auvmn ${DEST}/${CPRJ}/ ${SRCE}/${CPRJ}
@rsync -auvmn ${DEST}/${PPRJ}/ ${SRCE}/${PPRJ}
@echo "Restoring references .."
@rsync -auvmn ${DEST}/${CREF}/ ${SRCE}/${CREF}
@rsync -auvmn ${DEST}/${PREF}/ ${SRCE}/${PREF}
# Makefile for backup routines
# 2018 ckunte
#
SHELL=/usr/bin/bash
#
SOURCE=/cygdrive/c/apps
# current projects
CP=proj/curr
# past projects
PP=proj/past
# current references
CR=ref/cref
# past references
PR=ref/pref
#
# Choose one of the two servers (i.e., either local if on LAN, or
# remote, if access via WAN) and comment-out the other from below:
## For access from LAN (saves metered internet bandwidth)
SRV=<user>@<localip>
# For access from WAN
#SRV=<user>@<domainname>
#
DEST=$(SRV):/home/ckunte/d
#
# Flags (CLI options)
FLAGS=-vrldcmz --exclude-from=exclude.txt --delete --delete-excluded --progress
# For tunnelling with corkscrew
# PORT=-e 'ssh -D 443 -p 22'
# For direct access
PORT=-e 'ssh -p <custom port>'
default:
@echo 'Makefile for backup routines by Chetan Kunte'
@echo 'Usage:'
@echo ' make backup backup mail projects references'
@echo ' make mail backup mail'
@echo ' make proj backup projects'
@echo ' make cprj backup current projects'
@echo ' make pprj backup past projects'
@echo ' make aref backup references'
@echo ' make cref backup current references'
@echo ' make pref backup past references'
backup: mail proj aref
mail:
@echo 'Backing-up e-mail..'
@rsync $(FLAGS) $(SOURCE)/mail/ $(PORT) $(DEST)/mail
proj: cprj pprj
cprj:
@echo 'Backing-up current projects..'
@rsync $(FLAGS) $(SOURCE)/$(CP)/ $(PORT) $(DEST)/$(CP)
pprj:
@echo 'Backing-up past projects..'
@rsync $(FLAGS) $(SOURCE)/$(PP)/ $(PORT) $(DEST)/$(PP)
aref: cref pref
cref:
@echo 'Backing-up current references..'
@rsync $(FLAGS) $(SOURCE)/$(CR)/ $(PORT) $(DEST)/$(CR)
pref:
@echo 'Backing-up past references..'
@rsync $(FLAGS) $(SOURCE)/$(PR)/ $(PORT) $(DEST)/$(PR)
@ckunte

This comment has been minimized.

Owner

ckunte commented Sep 26, 2017

Console view:

screen shot 2017-09-26 at 10 42 32 pm

@lil5

This comment has been minimized.

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

This comment has been minimized.

Owner

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