diff --git a/home/.local/bin/gentoo-chroot b/home/.local/bin/gentoo-chroot new file mode 100755 index 0000000..fa903f6 --- /dev/null +++ b/home/.local/bin/gentoo-chroot @@ -0,0 +1,23 @@ +#!/bin/sh + +# Make sure the partition is mounted according to fstab +mount /mnt/gentoo 2>/dev/null + +# Mount necessary directories for chroot to be possible +mount --types proc /proc /mnt/gentoo/proc +mount --rbind /sys /mnt/gentoo/sys +mount --make-rslave /mnt/gentoo/sys +mount --rbind /dev /mnt/gentoo/dev +mount --make-rslave /mnt/gentoo/dev + +# Chroot with bash shell +chroot /mnt/gentoo /bin/bash + +# Unmount recursively mounted directories +umount -l /mnt/gentoo/dev{/shm,/pts,} +umount -R /mnt/gentoo + +# Remount partition accordingly to fstab +# (the above umountings will unmount gentoo completely, +# which means that remounting is necessary) +mount /mnt/gentoo diff --git a/home/.local/bin/incremental-backup b/home/.local/bin/incremental-backup new file mode 100755 index 0000000..ebe19a5 --- /dev/null +++ b/home/.local/bin/incremental-backup @@ -0,0 +1,31 @@ +#!/bin/bash + +# Script to perform incremental backups using rsync +# It is often ran as crontab rule for automated backup solution +# +# This script will respect .rsync-filter files, which can be used +# to define custom exclude rules for files/dirs in which it is present + +if [ $# -ne 2 ]; then + echo "Invalid amount of arguments passed!" + echo "Arguments: [Source path] [Backup path]" + echo " Source path: directory to be backed up, usually '/'" + echo " Backup path: directory to back up to (destination), usually mounted drive" + exit +fi + +SOURCE_DIR="$1" +BACKUP_DIR="$2" +DATETIME="$(date '+%Y-%m-%d_%H:%M:%S')" +BACKUP_PATH="${BACKUP_DIR}/${DATETIME}" +LATEST_LINK="${BACKUP_DIR}/latest" + +mkdir -p "$BACKUP_DIR" + +rsync -avHAXS \ + --delete \ + --filter='dir-merge /.rsync-filter' \ + --link-dest "${LATEST_LINK}" \ + "${SOURCE_DIR}/" "${BACKUP_PATH}" + +ln -sf "${BACKUP_PATH}" "${LATEST_LINK}" diff --git a/home/.local/bin/placeholder b/home/.local/bin/placeholder deleted file mode 100644 index e69de29..0000000