Skip to content

Instantly share code, notes, and snippets.

View firecat53's full-sized avatar

Scott Hansen firecat53

  • Lake Stevens, WA
View GitHub Profile
@firecat53
firecat53 / docker_backup.py
Created April 19, 2019 16:38
Backup docker volumes
#!/usr/bin/env python3
"""Backs up and restores data-only volumes to/from host backup directory using
rsync. Only backup named volumes, which is arbitrarily set to ones having a name
length < 40 characters.
1. Create a Docker image containing rsync (named rsync)
https://github.com/firecat53/dockerfiles/tree/master/rsync
``docker build -t rsync .``
-- Logs begin at Fri 2017-08-18 17:14:01 UTC, end at Fri 2017-08-18 17:14:57 UTC. --
Aug 18 17:14:01 minikube kernel: Linux version 4.9.13 (jenkins@jenkins) (gcc version 5.4.0 (Buildroot 2017.02) ) #1 SMP Tue Jul 18 22:17:02 UTC 2017
Aug 18 17:14:01 minikube kernel: Command line: BOOT_IMAGE=/boot/bzImage root=/dev/sr0 loglevel=3 console=tty0 noembed nomodeset norestore waitusb=10 systemd.legacy_systemd_cgroup_controller=yes initrd=/boot/initrd
Aug 18 17:14:01 minikube kernel: x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'
Aug 18 17:14:01 minikube kernel: x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
Aug 18 17:14:01 minikube kernel: x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers'
Aug 18 17:14:01 minikube kernel: x86/fpu: xstate_offset[2]: 576, xstate_sizes[2]: 256
Aug 18 17:14:01 minikube kernel: x86/fpu: Enabled xstate features 0x7, context size is 832 bytes, using 'standard' format.
Aug 18 17:14:01 minikube kernel: x86/fpu: Using 'eager' FPU context switches.
Au
@firecat53
firecat53 / Minikube error
Last active August 18, 2017 16:50
Minikube logs for localkube failure to start
~ $ minikube start --vm-driver=kvm -v9
Starting local Kubernetes v1.7.0 cluster...
Starting VM...
Found binary path at /usr/bin/docker-machine-driver-kvm
Launching plugin server for driver kvm
Plugin server listening at address 127.0.0.1:46215
() Calling .GetVersion
Using API Version 1
() Calling .SetConfigRaw
() Calling .GetMachineName
firecat53@62d52bac8d6f:/$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
258: eth0: <BROADCAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether d2:48:b0:71:26:93 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.41/16 scope global eth0
@firecat53
firecat53 / docker-enter
Last active August 29, 2015 14:03 — forked from mschuerig/docker-enter
Wrapper for nsinit and nsenter for easily accessing running Docker containers
#! /bin/bash
# Enter a running Docker container using either nsinit(preferred) or nsenter
# You can specify one or the other if desired.
# See
# http://blog.docker.com/2014/06/why-you-dont-need-to-run-sshd-in-docker/
# https://github.com/jpetazzo/nsenter
# https://gist.github.com/ubergarm/ed42ebbea293350c30a6 for compiling nsinit
[[ -n "$1" ]] || { echo "Usage: `basename $0` <container ID or name> [nsinit|nsenter]. Defaults to nsinit if available."; exit 0; }
@firecat53
firecat53 / keepass_kppy_pass.py
Last active August 29, 2015 14:03
Import keepass 1.x password database into GNU pass (no GUI required)
#!/bin/env python
"""Import keepass 1.x compatible password database into GNU pass
http://www.passwordstore.org/.
Uses the kppy (https://pypi.python.org/pypi/kppy) library to open and decode
the database. Python 2.7+ and Python 3.x compatible. Best results with Python3
for any unicode issues.
Usage: keepass2pass.py <keepass db> [--keyfile <key file if necessary>]
Based on http://git.zx2c4.com/password-store/tree/contrib/importers/keepassx2pass.py

Encrypted laptop setup

  • Btrfs on main drive, replacing GPT/MBR
  • Encrypted main drive using key file on flash drive. Add backup passphrase
  • No swap, swap files (limitation of Btrfs) or swap partition (so no suspend-to-disk)
  • Boot directory and grub on flash drive
  • 1st flash drive partition is Vfat partition to allow for cross-platform file transfers
  • Ext4 ISO partition for Linux-only data/ISO files, if desired.
  • TODO - edit grub to allow booting ISOs stored on the flash drive.
#!/usr/bin/env python3
"""Backs up data-only volumes to host backup directory using rdiff-backup.
First create a Docker image containing rdiff-backup (named rdiff-backup)
Dockerfile:
FROM ubuntu:precise
RUN apt-get update && apt-install -qy rdiff-backup
``docker build -rm -t rdiff-backup .``