Merge branch 'SupperSnapperRebuilds' into 'master'
Integrate Snapper into the system See merge request readynas-scripts/share_lun_ui_fix.sh!10
This commit is contained in:
commit
f83929341a
1 changed files with 79 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue