summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbackup.sh35
-rwxr-xr-xconnect-screen23
-rwxr-xr-xdump-ff-history11
-rwxr-xr-xhttpscert2
-rwxr-xr-xhttpstest2
-rw-r--r--logandkeep-stdout-stderr12
6 files changed, 68 insertions, 17 deletions
diff --git a/backup.sh b/backup.sh
index dd30db3..2301ce9 100755
--- a/backup.sh
+++ b/backup.sh
@@ -28,7 +28,7 @@
#
# See gpl-3.0.txt for full license text.
-set -e
+set -eu
main() {
if [[ $UID != 0 ]]; then
@@ -95,15 +95,19 @@ main() {
# This is called before creating the backup
pre_backup() {
- # save some data that's useful for restores
- local backupDataDir=/root/backup-data/
- mkdir -p "$backupDataDir"
- fdisk -l > "$backupDataDir/fdisk"
- vgdisplay > "$backupDataDir/vgdisplay"
- pvdisplay > "$backupDataDir/pvdisplay"
- lvdisplay > "$backupDataDir/lvdisplay"
- df -a > "$backupDataDir/df"
- findmnt -l > "$backupDataDir/findmnt"
+ if in_array_startswith '/root/backup-data/' "${source_paths[@]}"; then
+ # save some data that's useful for restores
+ local backupDataDir=/root/backup-data/
+ mkdir -p "$backupDataDir"
+ fdisk -l > "$backupDataDir/fdisk"
+ vgdisplay > "$backupDataDir/vgdisplay"
+ pvdisplay > "$backupDataDir/pvdisplay"
+ lvdisplay > "$backupDataDir/lvdisplay"
+ df -a > "$backupDataDir/df"
+ findmnt -l > "$backupDataDir/findmnt"
+ mdadm --detail --scan > "$backupDataDir/mdadm"
+ vgcfgbackup --file "$backupDataDir/vgcfgbackup"
+ fi
# If you wish to use snapshots, create them here
@@ -129,12 +133,17 @@ backup_borg() {
)
if tty -s; then
- options+=(--progress --stats)
+ options+=(--progress --stats --list --filter AME)
fi
borg create "${options[@]}" "$dst::$backup_prefix-$(date "+%Y%m%d-%H%M%S")" "${src[@]}"
- borg prune --prefix "backup-" --keep-within 7d --keep-daily 7 --keep-weekly 12 --keep-monthly 6 --keep-yearly 0 -v "$dst"
- borg prune --prefix "partial-" --keep-within 7d --keep-daily 7 --keep-weekly 12 --keep-monthly 6 --keep-yearly 0 -v "$dst"
+
+ # Only purge when doing full backups. Increases partial backup speed and
+ # ensure that we have at least one recent full backup when we purge.
+ if [[ $backup_prefix == 'backup-' ]]; then
+ borg prune --prefix "backup-" --keep-within 7d --keep-daily 7 --keep-weekly 12 --keep-monthly 6 --keep-yearly 0 -v "$dst"
+ borg prune --prefix "partial-" --keep-within 31d -v "$dst"
+ fi
}
### support functions below ###
diff --git a/connect-screen b/connect-screen
index cc1545d..58fa6cd 100755
--- a/connect-screen
+++ b/connect-screen
@@ -2,10 +2,29 @@
xrandr --output VIRTUAL1 --off
xrandr --output HDMI2 --off
+xrandr --output DP1 --off
+xrandr --output DP2 --off
xset r rate 250 50
-if xrandr | grep -q '^HDMI2 connected'; then
- xrandr --output HDMI2 --right-of eDP1 --auto
+has_hdmi2=$(xrandr | grep '^HDMI2 connected')
+has_dp1=$(xrandr | grep '^DP1 connected')
+has_dp2=$(xrandr | grep '^DP2 connected')
+
+if [[ $has_hdmi2 && $has_dp1 ]]; then
+ xrandr --output DP1 --right-of eDP1 --auto
+ xrandr --output HDMI2 --right-of DP1 --auto
+else
+ if [[ $has_hdmi2 ]]; then
+ xrandr --output HDMI2 --right-of eDP1 --auto
+ fi
+
+ if [[ $has_dp1 ]]; then
+ xrandr --output DP1 --right-of eDP1 --auto
+ fi
+
+ if [[ $has_dp2 ]]; then
+ xrandr --output DP2 --right-of eDP1 --auto
+ fi
fi
xkbcomp .xkbmap "$DISPLAY"
diff --git a/dump-ff-history b/dump-ff-history
new file mode 100755
index 0000000..5f16837
--- /dev/null
+++ b/dump-ff-history
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+TMPDIR="$(mktemp -d "/tmp/${0##*/}.XXXXXX")"
+trap "rm -rf '${TMPDIR}'" EXIT TERM
+
+cp -n ~/.mozilla/firefox/*.default/places.sqlite* "$TMPDIR"
+
+sqlite3 "$TMPDIR/places.sqlite" "SELECT datetime(visit_date/1000000,'unixepoch') AS visit_date, url, title
+FROM moz_places, moz_historyvisits
+WHERE moz_places.id = moz_historyvisits.place_id AND visit_date/1000000 > $(date +%s -d "${1:-2 months ago}") AND visit_date/1000000 < $(date +%s -d "${2:-now}")
+ORDER BY visit_date"
diff --git a/httpscert b/httpscert
index c2834c0..e5d44b1 100755
--- a/httpscert
+++ b/httpscert
@@ -1,3 +1,3 @@
#!/bin/bash
-httpstest $1 | sed -n '/-----BEGIN/,/-----END/p' | openssl x509 -text
+httpstest "$@"| sed -n '/-----BEGIN/,/-----END/p' | openssl x509 -text
diff --git a/httpstest b/httpstest
index e4fb0da..93dc9e0 100755
--- a/httpstest
+++ b/httpstest
@@ -2,4 +2,4 @@
# usage: httpstest <domain>
-openssl s_client -servername $1 -connect $1:443 </dev/null
+openssl s_client -servername $1 -connect $1:${2:-443} </dev/null
diff --git a/logandkeep-stdout-stderr b/logandkeep-stdout-stderr
new file mode 100644
index 0000000..7e8c09f
--- /dev/null
+++ b/logandkeep-stdout-stderr
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+# Mostly a snippet that you can copy to other scripts
+
+# Log stdout/stderr, but also keep them separate for use in e.g. crontab
+# (redirect stdout > /dev/null without losing stderr)
+exec > >(tee >(logger -t "${0##*/}"))
+exec 2> >(tee /dev/stderr | logger -t "${0##*/}")
+
+# demo
+echo "stdout message"
+echo "stderr message" >&2