1
1
scripts/README.md

97 lines
2.0 KiB
Markdown

# scripts
My personal collection of handy scripts. mostly bash.
- [restic-backup.sh](#restic-backup.sh)
- [restic-repos.sh](#restic-repos.sh)
- [btrfs-snapshots.sh](#btrfs-snapshots.sh)
- [odroid-fancontrol.sh](#odroid-fancontrol.sh)
More:
- [lib.sh](#lib.sh)
- [template.sh](#template.sh)
---
## restic-backup.sh
> This script is my very simple take on how to perform restic backups.
### Install
```bash
# Download
sudo su; cd
git clone https://git.socialnerds.org/david/scripts.git
ln -s /root/scripts/restic-backup.sh /usr/local/bin/restic-backup
```
```bash
# **** CONFIG ****
PASSWORD="/root/.restic-password"
REPO="sftp:<remote-server>:/path/to/repository"
KEEP=30
BIN="/usr/bin/restic"
OPTIONS="-p $PASSWORD -r $REPO -q"
```
You can run `restic_backup.sh` directly from the command line
```bash
# Usage
/root/restic_backup.sh /local/path <additional flags for the backup subcommand>
# Example
/root/restic_backup.sh /home -x -e ./.snapshots
```
or using cron.
```bash
# Cronjob
47 0 * * * /root/restic_backup.sh /home
# Cronjob (with healthchecks notification)
47 0 * * * /root/restic_backup.sh /home && curl -fsS -m 10 --retry 5 -o /dev/null https://checks.socialnerds.org/ping/fb721aec-5179-42c3-3455-4fd2ff39ii55
```
Happy backuping! :-)
## restic-repos.sh
## btrfs-snapshots.sh
## odroid-fancontrol.sh
## lib.sh
## template.sh
Use this as a base for new scripts, it already has the essentials.
```sh
# Load lib.sh
SCRIPT_LIB="lib.sh"
SCRIPT_PATH=$(readlink -f "$0")
SCRIPT_DIR=$(dirname "$SCRIPT_PATH")
if [[ -r "$SCRIPT_DIR/$SCRIPT_LIB" ]]; then
source "$SCRIPT_DIR/$SCRIPT_LIB"
lib_print "Loading version $LIB_GREEN_BOLD$LIB_VERSION$LIB_CLEAR of $LIB_GREEN_BOLD$LIB_NAME$LIB_CLEAR"
else
echo "Error: Cannot load library file [$SCRIPT_DIR/$SCRIPT_LIB]"
exit 1
fi
```
-----
## watch-containers.sh
Simple healthchecks script to monitor running containers.
## switch-desktop.sh
I think this is only useful with ElementaryOS. I use(d) this with a hot corner to control desktops with the mouse.