Skip to content

Instantly share code, notes, and snippets.

@enkore
enkore / borg-show-free-space.py
Last active August 23, 2023 18:01
Show freeable space in a borg repository.
"""
{[0]} path/to/hints.N
Show freeable space in a borg repository.
That is, amount of bytes accounted to deleted objects that have not been
compacted away yet.
"""
@enkore
enkore / borg-repository-v2.rst
Last active July 28, 2016 21:55
borg repository v2

Borg Repository V2

Design goals

  1. Separate object-data and metadata
  2. Allow aligning object-data on-disk
  3. Allow classification of objects (e.g. "this is a data chunk", "this is a metadata chunk")
(_venv)~/Projekte/_oss/borg> borg check ../linux-repo/ --info
Preparing repository check
Repository check phase 1 of 2: Checking segment integrity
Repository check phase 2 of 2: Checking index consistency
Completed repository check, no problems found.
Starting archive consistency check
Archive check phase 1 of 3: Building clean chunks index
Archive check phase 2 of 3: Rebuilding reference counts
Analyzing archive 1 of 2: l2
Analyzing archive 2 of 2: l1
@enkore
enkore / sketch.py
Last active July 2, 2016 21:29
borg doomable transactions as extra fail-safe
class Repository:
@staticmethod
def exception_dooms(whitelist=(,)):
"""All exceptions not on *whitelist* raised in the decorated method will doom the current transaction."""
def decorator(method):
def meth_wrapper(self, *args, **kwargs):
try:
return method(self, ...)
except Exception as exc:
@enkore
enkore / gist:9c556d4525c8ade8547081f2f25592b8
Created June 9, 2016 19:58
solaris sparse file output
jenkins@solaris11-1:~$ dd if=/dev/zero of=FILE1 bs=8k count=1 seek=1000
1+0 records in
1+0 records out
jenkins@solaris11-1:~$ stat FILE1
File: 'FILE1'
Size: 8200192 Blocks: 261 IO Block: 131072 regular file
Device: 13500010008h/1327144960008d Inode: 15666 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 100/ jenkins) Gid: ( 10/ staff)
Access: 2016-06-09 21:58:02.551877975 +0200
Modify: 2016-06-09 21:58:02.552275732 +0200
@enkore
enkore / test-cmac.c
Last active May 15, 2016 23:53
Simple test program for libcrypto (OpenSSL) CMAC
/* Simple test program for libcrypto (OpenSSL) CMAC
* $ gcc|clang test-cmac.c -lcrypto
*/
#define _POSIX_C_SOURCE 199309L
#include <stdint.h>
#include <stdio.h>
#include <time.h>
#include <assert.h>
@enkore
enkore / borg-dek.rst
Last active May 24, 2017 13:46
Borg DEK spec

Design goals for new cryptography in Borg

2017-04/05 update

CLK4.2:

  • Note that all type_byte || xxx constructions don't work unless type_byte != the current type bytes
@enkore
enkore / fuck-this-shit.sh
Last active February 25, 2016 12:56
shit-sucks.git, today's edition: Speedport W 724V
#!/bin/sh -e
# Written for Speedport W 724V firmware starting with 0101…
# This router is "smart" and "tracks" devices connected to the network. Instead
# of you just having a limited form to enter some iptables, you get to pick from a drop-down.
# But the router forgets devices that don't generate traffic directed to it every few minutes.
# And it updates the port forwarding rules, too. It justs sets them to the first or last seen IP
# in the DHCP range, even if DHCP is off.
#
# You'll need to run this with cron every few minutes to be sure that the port will be open most of the time.
@enkore
enkore / index.html
Created February 17, 2016 21:27
nginx SSI file to test two-way TLS authentication
<table>
<tr>
<td>HTTPS</td>
<td><!--# echo var="https" default="no" --></td>
</tr>
<tr>
<td>HTTP response</td>
<td><!--# echo var="status" --></td>
</tr>
<tr>
@enkore
enkore / konsole-cluster.sh
Last active February 1, 2016 01:23
konsole-cluster.sh: Something like cssh, just for KDE's Konsole
#!/bin/bash -e
#set -x
# Invocation
# $ konsole-cluster.sh host1 [[host_n] ...]
#
# 1. Creates a new Konsole window
# 2. Creates a tab for each argument, and runs $COMMAND in it
# 3. Raises the window
#