bak script
13. 7. 2025βSimpleβ version β
How would a simple (but not to simple) backup script look like? (something to avoid cp script script.bak
nonsense). After some long talk with my best friend Chad Gpt I came up with this:
- Make script relatively simple
- Donβt bother with directories (will only work with files)
- Donβt pollute current dir, backup to predefined folder instead
- Avoid duplicates via checksums
- Have timestamps to simulate basic version control
- Store with full paths
- Make shellcheck happy
So for example
bak shell.script
will copy that shell.script to predefined $HOME/bak
and store sha265 into $HOME/bak/.bak_index
Not tested very much, hot script
https://raw.githubusercontent.com/brontosaurusrex/bucentaur/refs/heads/master/.experiments/bin/bak
In action
β― echo "one" > script
β― cat script
one
β― bak script
β Backed up 'script' β '/home/b/bak/home/b/tmp/script.20250713-220753'
β― bak script
β Skipping 'script' β identical content already backed up
β― echo "two" >> script
β― bak script
β Backed up 'script' β '/home/b/bak/home/b/tmp/script.20250713-220811'
β― bak script
β Skipping 'script' β identical content already backed up
β― tree -a ~/bak
/home/b/bak
βββ .bak_index
βββ home
βββ b
βββ tmp
βββ script.20250713-220753
βββ script.20250713-220811
4 directories, 3 files
p.s. βrestore/unbakβ is up to the user manual labor.
Debate? https://forums.bunsenlabs.org/viewtopic.php?pid=144462#p144462
βGitβ version β
Could look like
https://raw.githubusercontent.com/brontosaurusrex/bucentaur/refs/heads/master/.experiments/bin/gitbak
Again, restore is up to the user and depends on the git knowhow.