mirror of
https://github.com/ghndrx/bash.git
synced 2026-02-10 14:55:10 +00:00
21 lines
604 B
Bash
Executable File
21 lines
604 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Exit if any command fails and treat unset variables as an error
|
|
set -eu
|
|
|
|
# Define the source and destination directories
|
|
src_dir="/home"
|
|
dst_dir="/opt/snapshots"
|
|
|
|
# Ensure the destination directory exists
|
|
mkdir -p "$dst_dir"
|
|
|
|
# Create a snapshot of the source directory
|
|
btrfs subvolume snapshot "$src_dir" "$dst_dir/desktop_snapshot_$(date +%Y%m%d%H%M%S)"
|
|
|
|
#/etc/crontab
|
|
# System Reboot takes a snapshot
|
|
# @reboot $HOME/snapshots/snapshot.sh
|
|
# Every 12 hours take a snapshot
|
|
# 0 */12 * * * $HOME/snapshots/snapshot.sh
|
|
@reboot /home/greg/Documents/github-repos/bash/scripts/snapshot-arch.sh |