File size: 2,129 Bytes
08985fa d724875 fbff4f9 d724875 08985fa 17f28ae c6cc4bd 5dc590b c6cc4bd 17f28ae 81da393 accb51f d724875 9ebdd97 811b3d3 c6cc4bd 7b04f2c d724875 c6cc4bd 7b04f2c c6cc4bd |
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 |
VERSION_CODENAME ?= $(shell grep VERSION_CODENAME /etc/os-release | cut -d'=' -f2)
VERSION_ID ?= $(shell grep VERSION_ID /etc/os-release | cut -d'=' -f2| tr -d '"')
VERSION_NAME ?= $(shell grep ^NAME= /etc/os-release | cut -d'=' -f2 | tr -d '"'| tr '[:upper:]' '[:lower:]')
HOSTNAME ?= $(shell hostname)
IMAGE_PROVIDER ?= docker.io
IMAGE_NAME ?= rafaelcalleja/distrostore
IMAGE_FLAVOR ?= GNOME
IMAGE_TAG ?= $(VERSION_NAME)-$(VERSION_ID)-$(IMAGE_FLAVOR)
IMAGE ?= $(IMAGE_NAME):$(IMAGE_TAG)
REPOSITORY ?= hf.co/$(IMAGE)
GOPASS_FILE ?= .autorestic.yml
GOPASS_KEY ?= $(REPOSITORY)/$(GOPASS_FILE)
CURRENT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
COMMIT_MESSAGE ?= $(shell date)
RESTORE_DST ?= /tmp/restore
RESTORE_FROM ?= hdd
RESTORE_LOCATION ?= root_backup
SSH_USER ?= $(shell whoami)
SSH_HOST ?= $(shell ip addr show | grep -A 2 'eth' | grep inet | awk '{print $$2}' | cut -d/ -f1 | head -n 1)
SSH_AUTH_SOCK ?= $(shell echo ${SSH_AUTH_SOCK})
default: backup
backup:
time autorestic -c $(CURRENT_DIR)/$(GOPASS_FILE) backup -a && \
git add -A && \
git commit -m "$(COMMIT_MESSAGE)" && \
git push
restore:
cd $(RESTORE_DST); time autorestic restore --from $(RESTORE_FROM) -l $(RESTORE_LOCATION) -c $(CURRENT_DIR)/$(GOPASS_FILE)
save:
gopass insert -f $(GOPASS_KEY) < $(GOPASS_FILE)
load:
gopass show $(GOPASS_KEY) >$(GOPASS_FILE)
show-cron:
@cat $(CURRENT_DIR)/.cron | sed "s|CURRENT_DIR|$(CURRENT_DIR)|g"
build:
docker run --rm --privileged -e BUILDKITD_FLAGS="--allow-insecure-entitlement security.insecure" \
--volume $(CURRENT_DIR):/tmp/work \
--volume "$${HOME}/.docker:/root/.docker:ro" \
--volume $(SSH_AUTH_SOCK):$(SSH_AUTH_SOCK) \
--volume $(RESTORE_DST):$(RESTORE_DST) \
--entrypoint buildctl-daemonless.sh \
moby/buildkit:master \
build \
--frontend dockerfile.v0 \
--local context=/tmp/work \
--local dockerfile=/tmp/work \
--allow security.insecure \
--opt build-arg:SSH_USER=$(SSH_USER) \
--opt build-arg:SSH_HOST=$(SSH_HOST) \
--opt build-arg:ROOTFS=$(RESTORE_DST) \
--output type=image,name=$(IMAGE_PROVIDER)/$(IMAGE),push=true \
--ssh default=$(SSH_AUTH_SOCK)
|