added config to manage keep for every cron
This commit is contained in:
19
Makefile
19
Makefile
@@ -1,18 +1,27 @@
|
||||
.PHONY: all install uninstall
|
||||
|
||||
# Load retention configuration (KEEP_FREQUENT, KEEP_HOURLY, KEEP_DAILY, KEEP_WEEKLY, KEEP_MONTHLY)
|
||||
include zfs-auto-snapshot.conf
|
||||
|
||||
all:
|
||||
|
||||
# Install or update cron files with configured retention values
|
||||
install:
|
||||
install -d /etc/cron.d
|
||||
install -d /etc/cron.daily
|
||||
install -d /etc/cron.hourly
|
||||
install -d /etc/cron.weekly
|
||||
install -d /etc/cron.monthly
|
||||
install -m 0644 etc/zfs-auto-snapshot.cron.frequent /etc/cron.d/zfs-auto-snapshot
|
||||
install -m 0755 etc/zfs-auto-snapshot.cron.hourly /etc/cron.hourly/zfs-auto-snapshot
|
||||
install -m 0755 etc/zfs-auto-snapshot.cron.daily /etc/cron.daily/zfs-auto-snapshot
|
||||
install -m 0755 etc/zfs-auto-snapshot.cron.weekly /etc/cron.weekly/zfs-auto-snapshot
|
||||
install -m 0755 etc/zfs-auto-snapshot.cron.monthly /etc/cron.monthly/zfs-auto-snapshot
|
||||
sed 's/@KEEP_FREQUENT@/$(KEEP_FREQUENT)/g' etc/zfs-auto-snapshot.cron.frequent > /etc/cron.d/zfs-auto-snapshot
|
||||
chmod 0644 /etc/cron.d/zfs-auto-snapshot
|
||||
sed 's/@KEEP_HOURLY@/$(KEEP_HOURLY)/g' etc/zfs-auto-snapshot.cron.hourly > /etc/cron.hourly/zfs-auto-snapshot
|
||||
chmod 0755 /etc/cron.hourly/zfs-auto-snapshot
|
||||
sed 's/@KEEP_DAILY@/$(KEEP_DAILY)/g' etc/zfs-auto-snapshot.cron.daily > /etc/cron.daily/zfs-auto-snapshot
|
||||
chmod 0755 /etc/cron.daily/zfs-auto-snapshot
|
||||
sed 's/@KEEP_WEEKLY@/$(KEEP_WEEKLY)/g' etc/zfs-auto-snapshot.cron.weekly > /etc/cron.weekly/zfs-auto-snapshot
|
||||
chmod 0755 /etc/cron.weekly/zfs-auto-snapshot
|
||||
sed 's/@KEEP_MONTHLY@/$(KEEP_MONTHLY)/g' etc/zfs-auto-snapshot.cron.monthly > /etc/cron.monthly/zfs-auto-snapshot
|
||||
chmod 0755 /etc/cron.monthly/zfs-auto-snapshot
|
||||
install -d /usr/local/sbin
|
||||
install -m 0755 src/zfs-auto-snapshot.sh /usr/local/sbin/zfs-auto-snapshot
|
||||
|
||||
|
||||
13
README.md
13
README.md
@@ -19,6 +19,19 @@ Originally adapted from https://github.com/zfsonlinux/zfs-auto-snapshot
|
||||
make install
|
||||
```
|
||||
|
||||
## Configuration
|
||||
Snapshot retention limits can be configured in `zfs-auto-snapshot.conf`:
|
||||
- `KEEP_FREQUENT`: snapshots rotated every 15 minutes (default: `4`)
|
||||
- `KEEP_HOURLY`: hourly snapshots (default: `24`)
|
||||
- `KEEP_DAILY`: daily snapshots (default: `31`)
|
||||
- `KEEP_WEEKLY`: weekly snapshots (default: `12`)
|
||||
- `KEEP_MONTHLY`: monthly snapshots (default: `12`)
|
||||
|
||||
To apply configuration changes and update installed cron files, run:
|
||||
```sh
|
||||
make install
|
||||
```
|
||||
|
||||
## Uninstallation
|
||||
```sh
|
||||
make uninstall
|
||||
|
||||
@@ -4,4 +4,4 @@ PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH"
|
||||
# Only call zfs-auto-snapshot if it's available
|
||||
command -v zfs-auto-snapshot >/dev/null 2>&1 || exit 0
|
||||
|
||||
exec zfs-auto-snapshot --label daily --keep 31
|
||||
exec zfs-auto-snapshot --label daily --keep @KEEP_DAILY@
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
|
||||
*/15 * * * * root command -v zfs-auto-snapshot >/dev/null 2>&1 && exec zfs-auto-snapshot --label quarterhour --keep 4
|
||||
*/15 * * * * root command -v zfs-auto-snapshot >/dev/null 2>&1 && exec zfs-auto-snapshot --label quarterhour --keep @KEEP_FREQUENT@
|
||||
|
||||
@@ -4,4 +4,4 @@ PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH"
|
||||
# Only call zfs-auto-snapshot if it's available
|
||||
command -v zfs-auto-snapshot >/dev/null 2>&1 || exit 0
|
||||
|
||||
exec zfs-auto-snapshot --label hourly --keep 24
|
||||
exec zfs-auto-snapshot --label hourly --keep @KEEP_HOURLY@
|
||||
|
||||
@@ -4,4 +4,4 @@ PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH"
|
||||
# Only call zfs-auto-snapshot if it's available
|
||||
command -v zfs-auto-snapshot >/dev/null 2>&1 || exit 0
|
||||
|
||||
exec zfs-auto-snapshot --label monthly --keep 12
|
||||
exec zfs-auto-snapshot --label monthly --keep @KEEP_MONTHLY@
|
||||
|
||||
@@ -4,4 +4,4 @@ PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH"
|
||||
# Only call zfs-auto-snapshot if it's available
|
||||
command -v zfs-auto-snapshot >/dev/null 2>&1 || exit 0
|
||||
|
||||
exec zfs-auto-snapshot --label weekly --keep 12
|
||||
exec zfs-auto-snapshot --label weekly --keep @KEEP_WEEKLY@
|
||||
|
||||
11
zfs-auto-snapshot.conf
Normal file
11
zfs-auto-snapshot.conf
Normal file
@@ -0,0 +1,11 @@
|
||||
# ==============================================================================
|
||||
# zfs-auto-snapshot Retention Configuration
|
||||
# ==============================================================================
|
||||
# Number of snapshots to retain for each cron schedule.
|
||||
# Modify these values and run 'make install' to apply.
|
||||
|
||||
KEEP_FREQUENT=4
|
||||
KEEP_HOURLY=24
|
||||
KEEP_DAILY=31
|
||||
KEEP_WEEKLY=12
|
||||
KEEP_MONTHLY=12
|
||||
Reference in New Issue
Block a user