Compare commits
2 Commits
cf1f43ca9f
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| a5056198ab | |||
| dceb17cd57 |
@@ -6,3 +6,4 @@ Some helpful bash scripts for [incus](https://linuxcontainers.org/incus)
|
|||||||
- incus-backup: Backup instances FS and DBs to a remote location using rsync over ssh.
|
- incus-backup: Backup instances FS and DBs to a remote location using rsync over ssh.
|
||||||
- incus-copy: Run a differential copy of all running instances to a remote incus server.
|
- incus-copy: Run a differential copy of all running instances to a remote incus server.
|
||||||
- incus-snapshot: Take a snapshot on all running instances.
|
- incus-snapshot: Take a snapshot on all running instances.
|
||||||
|
- zfs-auto-snapshot: Create and cleanup expired zfs snapshots.
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ done
|
|||||||
|
|
||||||
for CT in $(/usr/bin/incus list -c n -f compact,noheader status=RUNNING) ; do
|
for CT in $(/usr/bin/incus list -c n -f compact,noheader status=RUNNING) ; do
|
||||||
DATE=$(date '+%Y-%m-%d %H:%M:%S')
|
DATE=$(date '+%Y-%m-%d %H:%M:%S')
|
||||||
echo "[${DATE}] incus copy ${CT} ${DEST}:$CT --refresh --mode push"
|
CMD="/usr/bin/incus copy $CT ${DEST}:$CT --refresh --refresh-exclude-older --mode ${MODE}"
|
||||||
/usr/bin/incus copy $CT ${DEST}:$CT --refresh --mode ${MODE} 2>&1 > /dev/null
|
echo "[${DATE}] $CMD"
|
||||||
|
$CMD 2>&1 > /dev/null
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
29
zfs-auto-snapshot.sh
Executable file
29
zfs-auto-snapshot.sh
Executable file
@@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Create zfs snapshots for $DATASET
|
||||||
|
# https://github.com/bahamas10/zfs-prune-snapshots
|
||||||
|
#
|
||||||
|
|
||||||
|
#set -x
|
||||||
|
|
||||||
|
while getopts d:e: flag
|
||||||
|
do
|
||||||
|
case "${flag}" in
|
||||||
|
d) DATASET=${OPTARG};;
|
||||||
|
e) EXPIRATION=${OPTARG};;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
DATE=$(date '+%Y-%m-%d %H:%M:%S')
|
||||||
|
|
||||||
|
TS=$(date '+%s')
|
||||||
|
ZFS=$(which zfs)
|
||||||
|
CMD="$ZFS snapshot ${DATASET}@snap${TS}"
|
||||||
|
echo "[${DATE}] $CMD"
|
||||||
|
$CMD 2>&1 > /dev/null
|
||||||
|
|
||||||
|
ZFS_PRUNE_SNAPSHOTS=$(which zfs-prune-snapshots)
|
||||||
|
CMD="$ZFS_PRUNE_SNAPSHOTS -p 'snap' $EXPIRATION $DATASET"
|
||||||
|
echo "[${DATE}] $CMD"
|
||||||
|
$CMD 2>&1 > /dev/null
|
||||||
|
|
||||||
Reference in New Issue
Block a user