From ca6b824a82bc8f277c370b4ae24ba40d248988ce Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Thu, 5 Sep 2024 08:43:25 +0100 Subject: Adds documents backup and note_importer scripts --- documents-backup.sh | 8 ++++++++ note_importer.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100755 documents-backup.sh create mode 100755 note_importer.sh diff --git a/documents-backup.sh b/documents-backup.sh new file mode 100755 index 0000000..f317d84 --- /dev/null +++ b/documents-backup.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Define the source and destination directories +SRC_DIR=/home/$USER/Documents +DST_HOST=bach:/mnt/encrypted/matt_backups/ + +# Run rsync command using ssh for encryption +rsync -avz --delete "$SRC_DIR" "$DST_HOST" diff --git a/note_importer.sh b/note_importer.sh new file mode 100755 index 0000000..fda041a --- /dev/null +++ b/note_importer.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Check if file was provided as argument +if [ -z "$1" ]; then + echo "Error: No file specified." + exit +fi + +# Display file in pager (less) +less "$1" + +# Ask user if they want to import the file +echo "Import this file? (y/n)" +read -r IMPORT_RESPONSE + +if [ "${IMPORT_RESPONSE,,}" = "n" ]; then + # Ask user if they want to delete the file + echo "Delete this file instead? (y/n)" + read -r DELETE_RESPONSE + + case ${DELETE_RESPONSE,,} in + y) rm "$1"; exit ;; + n) exit ;; + esac + +else + # Append contents of file to scratchpad.txt + NOTE=$(basename -s .md -- "$1") + cat >> ~/Documents/Notes/Scratch/scratchpad.txt <