I have started making bash scripts for converting various backup snapshots from one tool to another. So far I've covered: - Borg to Restic - Borg to Kopia They work quite fine, though Restic and Kopia lack the ability to change the root directory of the backup so if your script extracts to a unique temporary directory for each snapshot then you got some confusing output about no files being cached (Kopia) even though…
Ask HN: Small scripts, hacks and automations you're proud of?
161–170 of 340 posts
Re: Ask HN: Small scripts, hacks and automations you're proud of?
#162https://github.com/harish2704/dotFiles/blob/master/home/.loc...
This script + SpaceFM file manager saving lot of time for me
Re: Ask HN: Small scripts, hacks and automations you're proud of?
#163Re: Ask HN: Small scripts, hacks and automations you're proud of?
#164Re: Ask HN: Small scripts, hacks and automations you're proud of?
#165I wrote a script on top of Puppeteer that would be called from crontab on my home server, to go to the reservation page, press the buttons to flip through the calendar and extract days with vacancy (the reservation app is an SPA). When there were new vacancies it would send me a message through one of the messaging APIs about new dates available, so I could see if it aligns with our schedule and book immediately from the phone wherever I am.
That actually worked like a charm and I snatched a very convenient reservation after few days.
Re: Ask HN: Small scripts, hacks and automations you're proud of?
#166 #!/usr/bin/env bash
set -o errexit
set -o nounset
usage(){
printf "[TRACE=...] %s [-b /path/to/clones/root] (%s/w) -- \n" "${0##*/}" "$HOME"
}
if [[ -n "${TRACE-}" ]]; then
set -o xtrace
fi
trap 'set +o xtrace' ALRM HUP INT TERM EXIT
: "${GIT_BASE:=$HOME}"
while getopts b:h OPT; do
case "$OPT" in
b) GIT_BASE="$OPTARG";;
h) usage; exit 0;;
*) ;;
esac
done
shift $(( OPTIND - 1 ))
while read -r REPO; do
[[ -d "$REPO"/.git ]] || continue
[[ "$REPO" =~ \.terraform\/modules ]] && continue
tput setaf 8
printf "%s … %s\n" "$REPO" "$( git -C "$REPO" config --local --get remote.origin.url )"
tput sgr0
if [[ $# -eq 0 ]]; then
git -C "$REPO" status -sb
else
git -C "$REPO" "$@"
fi
printf "\n"
done Re: Ask HN: Small scripts, hacks and automations you're proud of?
#167I have started making bash scripts for converting various backup snapshots from one tool to another. So far I've covered: - Borg to Restic - Borg to Kopia They work quite fine, though Restic and Kopia lack the ability to change the root directory of the backup so if your script extracts to a unique temporary directory for each snapshot then you got some confusing output about no files being cached (Kopia) even though…
Since you have used several backup tools, I wonder which one you recommend.
It's honestly a win on all fronts. It can sync to remote places -- which I don't care about as I have a local directory where it does its stuff and I then distribute that with `rclone` to several encrypted cloud accounts -- BUT many people do care so to them it's an even bigger win.
So yeah, I tried Borg and Restic and Kopia and Kopia wins by all accounts: size of backup directory and speed of operation at least.
(One thing I should mention is that Kopia is also very aggressive at eliminating duplicate snapshots and sometimes you might find yourself lacking snapshots for e.g. five days as it happened with me; however, upon very close inspection -- think unpacking the two snapshots before and after that period, and checking diffs, it turned out that I lost nothing, everything I wanted was still there. But, it's a disclaimer one way or another. Plus, its policy for retaining stuff is not like that of e.g. Borg. Make sure to read up a bit on it before using. Again, it never loses data but it has a different opinion on what is "the last 10 hourly snapshots" compared to Borg.)
Re: Ask HN: Small scripts, hacks and automations you're proud of?
#168A simple diary script. `$ diary` to create/open a file for today's diary in vim: https://github.com/Aperocky/diaryman/blob/master/diaryman.sh Or try `pip install diarycli`: https://github.com/Aperocky/diarycli , for a pip packaged python version that does the exact same thing. I've actually kept diary and work logs, things I did not know I was capable of.
Re: Ask HN: Small scripts, hacks and automations you're proud of?
#169Anyway, when working on feature branches I wanted a quick way to switch to master, pull, switch back and finally rebase.
So I made a little script (https://gist.github.com/lelanthran/6c9bd1125f89e7621364878d1...) that pushes the current branch name onto a stack before switching to a new branch, and allows me to switch back to the topmost branch on the stack.
xgit master # Switch to master from current
git pull
xgit pop # Switches back to
git rebase master
I use this now very frequently; when I need to switch to branches I use `xgit `, because then I can switch back easily using `xgit pop`.Re: Ask HN: Small scripts, hacks and automations you're proud of?
#170There is a specific small hotel that will remain unnamed, which my partner wanted to book for a long long time. At any given moment if you check the reservations page, it is most likely booked for two years solid. It is famous enough that people book it all the time, but it has lenient cancellation policy of 100% refund if cancelled before 2 weeks. This is not really a problem for them as these vacancies get booked i…