From c1b25aa875feb70a0c628a29716cc3d846626efd Mon Sep 17 00:00:00 2001 From: Cody Cook Date: Mon, 1 Apr 2019 23:42:57 -0700 Subject: [PATCH] math idiocy. fix the count of shares instead of total shares, since do not want gaps in the snapper configs and isn't applicable to iscsi --- share_lun_ui_fix.sh | 80 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/share_lun_ui_fix.sh b/share_lun_ui_fix.sh index dbaf621..bd575d5 100755 --- a/share_lun_ui_fix.sh +++ b/share_lun_ui_fix.sh @@ -11,6 +11,18 @@ mvcmd="mv" ################ ### commands ### ################ + +backupsnappershots() { + echo "==== [Task] Backing up existing Snapper configs" + tar -cf "/var/backups/backup_snapper_configs.$(date +%s).tar" /etc/snapper/configs 2>/dev/null + if [[ $? ]]; then + echo "===== [Info] Success at backing up snapper configs" + echo "===== [Task] Removing Snapper Configs" + rm /etc/snapper/configs/* 2>/dev/null + else + echo "===== [Fail] Couldn't backup configs. Please debug" + fi +} share_create() { found=$((found+1)) shares=$((shares+1)) @@ -79,10 +91,75 @@ EOF writeable = 1 follow symlinks = 1 EOF - cd "$path" + + cat > /etc/snapper/$((shares-1)) << EOF + +# subvolume to snapshot +SUBVOLUME="/$volume/$item" + +# filesystem type +FSTYPE="btrfs" + + +# btrfs qgroup for space aware cleanup algorithms +QGROUP="" + + +# fraction of the filesystems space the snapshots may use +SPACE_LIMIT="0.5" + + +# users and groups allowed to work with config +ALLOW_USERS="guest" +ALLOW_GROUPS="admin" + +# sync users and groups from ALLOW_USERS and ALLOW_GROUPS to .snapshots +# directory +SYNC_ACL="no" + + +# start comparing pre- and post-snapshot in background after creating +# post-snapshot +BACKGROUND_COMPARISON="yes" + + +# run daily number cleanup +NUMBER_CLEANUP="yes" + +# limit for number cleanup +NUMBER_MIN_AGE="1800" +NUMBER_LIMIT="50" +NUMBER_LIMIT_IMPORTANT="10" + + +# create hourly snapshots +TIMELINE_CREATE="yes" + +# cleanup hourly snapshots after some time +TIMELINE_CLEANUP="yes" + +# limits for timeline cleanup +TIMELINE_MIN_AGE="1800" +TIMELINE_LIMIT_HOURLY="10" +TIMELINE_LIMIT_DAILY="10" +TIMELINE_LIMIT_WEEKLY="0" +TIMELINE_LIMIT_MONTHLY="10" +TIMELINE_LIMIT_YEARLY="10" + + +# cleanup empty pre-post-pairs +EMPTY_PRE_POST_CLEANUP="yes" + +# limits for empty pre-post-pair cleanup +EMPTY_PRE_POST_MIN_AGE="1800" + +SNAPSHOT_HWM="13" +EOF + cd "$path" chown root.root datasettype.conf recycle.conf snapdir.conf snapshot.conf chown admin.admin afp.conf fs.conf ftp.conf nfs.conf samba.conf custom_snapshot_management.conf custom_snapshot_schedule.conf chmod 644 datasettype.conf recycle.conf snapdir.conf snapshot.conf afp.conf fs.conf ftp.conf nfs.conf samba.conf custom_snapshot_management.conf custom_snapshot_schedule.conf + chmod 640 /etc/snapper/configs/$((shares-1)) echo "==== [Info] Done with Share /$volume/$item." } @@ -192,6 +269,7 @@ else echo "=== [Info] Number of items found : $(echo $objects | wc -w)" echo "=== [Info] Items found:" $objects backup_configs + backupsnappershots for item in $objects; do echo "=== [Task] Reviewing $item" if ! btrfs subv show /"$volume"/"$item" &>/dev/null; then