Skip to content

Instantly share code, notes, and snippets.

$ systemctl list-timers --all
NEXT LEFT LAST PASSED UNIT ACTIVATES
Mon 2019-08-12 00:00:00 -05 3h 0min left n/a n/a borgbackup-job-main.timer borgbackup-job-main.service
Mon 2019-08-12 00:00:00 -05 3h 0min left n/a n/a docker-prune.timer docker-prune.service
Mon 2019-08-12 00:00:00 -05 3h 0min left n/a n/a nix-gc.timer nix-gc.service
Mon 2019-08-12 00:00:00 -05 3h 0min left n/a n/a restic-backups-home.timer restic-backups-home.service
Mon 2019-08-12 01:41:24 -05 4h 42min left Sun 2019-08-11 19:41:24 -05 1h 17min ago update-dnscrypt-resolvers.timer update-dnscrypt-resolvers.service
Mon 2019-08-12 19:51:35 -05 22h left Sun 2019-08-11 19:51:35 -05 1h 7min ago systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
# Sign-up at https://www.borgbase.com/
# Generate key pair (password? luks?)
$ ssh-keygen -o -a 100 -t ed25519
# Upload public key to borgbase as APPEND-ONLY
$ cat ~/.ssh/id_ed25519.pub
# Check plan capacity vs total backup size, then pay! ;)
# Sign-up at https://www.backblaze.com/ and raise the CAPS
# Setup parameters on the environment
$ export B2_ACCOUNT_ID=X
$ export B2_ACCOUNT_KEY=Y
$ export RESTIC_REPOSITORY=b2:ralvarezc:auto
$ export RESTIC_PASSWORD_FILE=$HOME/.secrets/restic
# Install restic
$ nix-env -i restic
$ cryptsetup luksDump /dev/nvme0n1p1
(only one slot used)
$ dd if=/dev/urandom of=./keyfile.bin bs=1024 count=4
$ cryptsetup luksAddKey /dev/nvme0n1p1 ./keyfile.bin
(two slots used, 0 for passphrase, 1 for keyfile)
$ cryptsetup luksDump /dev/nvme0n1p1
$ sudo su -
# echo ./keyfile.bin | cpio -o -H newc -R +0:+0 --reproducible | gzip -9 > /boot/initrd.keys.gz
## Edit configuration.nix
nix-env -e vim
nix-env -i vim
nix-env -qaP '*'|grep vim
ralvarez@auto  ~  sudo nixos-rebuild switch --upgrade --keep-going
ralvarez@auto  ~  du -sh /nix
47G /nix
ralvarez@auto  ~  sudo nix-store --optimise
13313.45 MiB freed by hard-linking 1486666 files
ralvarez@auto  ~  du -sh /nix
30G /nix
ralvarez@auto  ~  sudo nix-collect-garbage
....
deleting unused links...
note: currently hard linking saves -0.00 MiB
1613 store paths deleted, 5080.77 MiB freed
ralvarez@auto  ~  df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 779M 0 779M 0% /dev
tmpfs 7.7G 121M 7.5G 2% /dev/shm
tmpfs 3.9G 7.0M 3.8G 1% /run