~jonn/archive-trap

b90ffe172834735c25bf3e8e8c7be70a3cc34c0c — cognivore 3 years ago 4737ce6
Problem: Outdated instructions in README, old conf

Solution:

 - Update README with a more sleek way to run Archive Trap
 - Update ArchiveTrap with more advanced config
2 files changed, 27 insertions(+), 10 deletions(-)

M README.md
M src/ArchiveTrap.hs
M README.md => README.md +17 -6
@@ 8,18 8,29 @@
     - Run a command akin to this:

```
# Do this step once
sudo su
git config --global user.name "root"
git config --global user.email "root@localhost"
exit
stack build && sudo rm -rvf /tmp/archive-trap-secure/ && sudo cp -rv
~/.ssh /root/ && sudo
.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.0.1.0/build/archive-trap-exe/archive-trap-exe

# Do this step to run backup
stack build --copy-bins && \
  sudo rm -rvf "/tmp/archive-trap-secure/" ; sudo cp -rv "$HOME/.ssh" "/root/" && \
  sudo "$HOME/.local/bin/archive-trap-exe"

# Explanation:
#   - `stack build`: rebuild the project with your new configuration
#   - `sudo cp -rv ~/.ssh ...`: make sure `root` can pull from Git
#   - `sudo .stack-work ...`: run archive trap. Sudo needed to capture other people's home directories.
 # stack build --copy-bins: Will copy `archive-trap-exe` into your ~/.local/bin
 # rm -rvf /tmp/archive-trap-secure/: Will make sure you don't have
   # secure repo cloned anymore
 # cp -rv "$HOME/.ssh" "/root/": Will copy your private key to root home
   # directory (I assume that your threat model is such that if root is
   # compromised your user is also compromised, so it's fine. Just don't
   # forget about this bit if you have some scripts to wipe your private
   # info from a computer quickly)
 # sudo "$HOME/.local/bin/archive-trap-exe": Actually runs the backup
   # script. Sudo is needed to grab configs from other users if needed.

```

## What is this

M src/ArchiveTrap.hs => src/ArchiveTrap.hs +10 -4
@@ 1,7 1,7 @@
{-# LANGUAGE OverloadedStrings #-}
module ArchiveTrap (red, green, relevant, secureGitRepo, computerType) where

import Turtle ( Text, FilePath, lsdepth, Shell )
import Turtle ( Text, FilePath, lsdepth, Shell, cat )
import Prelude hiding (FilePath)
import Turtle.Directory.Filter
    ( mkGreen,


@@ 50,19 50,25 @@ green = Just $ mkGreen [ mkPrefix "/etc/nginx"
                       , linuxAnyUser Nothing (Just ".Xdemo")
                       , linuxAnyUser Nothing (Just ".ssh/config")
                       , linuxAnyUser Nothing (Just ".ssh/known_hosts")
                       , linuxAnyUser Nothing (Just ".tmux.conf")

                       -- Mail stuff
                       -- Mail / Git stuff
                       , linuxAnyUser Nothing (Just ".muttrc")
                       , linuxAnyUser (Just ".mutt/includes") Nothing
                       , linuxAnyUser (Just ".mutt/tasks") Nothing

                       , linuxAnyUser Nothing (Just ".fetchmailrc")
                       , linuxAnyUser Nothing (Just ".procmailrc")
                       , linuxAnyUser Nothing (Just ".gpg.rc")
                       ]

relevant :: Shell FilePath
relevant = lsdepth 1 4 "/"
relevant = cat [lsdepth 1 3 "/etc/", lsdepth 1 3 "/home/"]

type Infix = FilePath
type Suffix = FilePath

linuxAnyUser :: Maybe FilePath -> Maybe FilePath -> SimpleRule
linuxAnyUser :: Maybe Infix -> Maybe Suffix -> SimpleRule
linuxAnyUser xinf xsuf = SimpleRule {
  tdfr_prefix = Just "/home",
  tdfr_infix  = xinf,